Skip to content

Commit 73d5c6c

Browse files
dmealingclaude
andcommitted
docs(python): --generators takes one tier without the rest
An estate whose tables come from `meta migrate` and whose application code is not generated at all still had 37 hard-coded table names and 16 column-name reads across four services — exactly what `names` exists for. Nothing documented that it can be taken on its own, so the reachable options looked like "adopt the whole Python suite" or "keep the literals". `--generators names` is that answer, and it is measured rather than asserted: on the 16-entity persistence-conformance model the default suite emits 68 files and this emits 19. The `--column-naming` trap is stated with the consequence, because the default differs from the tool that built the schema: `literal` here (matching this port's ObjectManager) against `meta migrate`'s `snake_case`, so the default emits `PROGRAM_PRICE_CENTS_COLUMN = "priceCents"` for a column named `price_cents` — a constant naming a column that does not exist, which is worse than the literal it replaced. Every claim on the page was produced by running the command; the first draft had two that the output contradicted (the map and schema constants are entity-prefixed, and the schema constant only appears when the source declares `@schema`). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTcEKXTQMYt84fAjuw5A2M
1 parent 2005949 commit 73d5c6c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

docs/ports/python.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,34 @@ read a declarative [`metaobjects.config.yaml`](../features/cli.md) (#267) — ru
101101
either with no positional `<metadata_dir>` to use it; the flag path above stays
102102
byte-identical.
103103

104+
### Taking one tier and not the rest
105+
106+
`--generators <csv>` runs exactly the named generators instead of the default
107+
suite (`--list` names all of them). This is the answer for a project that wants
108+
one tier without adopting the others — most often a **schema-only adopter** whose
109+
tables come from `meta migrate` and whose application code is not generated at all,
110+
but which still has physical table and column names hard-coded across its data
111+
layer:
112+
113+
```bash
114+
metaobjects gen ./metadata --out ./generated --generators names
115+
```
116+
117+
It emits one `<entity>_names.py` per object and nothing else. Each carries
118+
`<ENTITY>_SOURCE_PRIMARY_TABLE`, a `<ENTITY>_<FIELD>_COLUMN` per field, a
119+
`<ENTITY>_COLUMNS_BY_FIELD` map, and `<ENTITY>_SOURCE_PRIMARY_SCHEMA` when the
120+
source declares a `@schema`. On the 16-entity persistence-conformance model the
121+
default suite emits 68 files and this emits 19 — so adopting the names tier does
122+
not drag a REST surface into a repo that does not want one.
123+
124+
**Pass the same `--column-naming` the schema was created with.** It defaults to
125+
`literal` here, matching this port's `ObjectManager` — **not** `meta migrate`'s
126+
`snake_case`. On a schema built by `meta migrate`, the default emits
127+
`PROGRAM_PRICE_CENTS_COLUMN = "priceCents"` for a column actually named
128+
`price_cents`: a constant that names a column which does not exist, which is worse
129+
than the literal it replaced. Use `--column-naming snake_case` there. (A field
130+
carrying an explicit `@column` is unaffected either way.)
131+
104132
**Both `pydantic` and `fastapi` are consumer-installed, not transitive deps of
105133
`metaobjects` itself** — the entity/router files this emits `import pydantic`
106134
and `import fastapi`, so add them before importing the generated code:

0 commit comments

Comments
 (0)