Repository navigation
Commit 09b312c
fix(python-codegen): @column is the column name, not the model's field name
The generated `<Entity>` read model named its Pydantic field
`@column or field.name`. Everything else in the port keys by `field.name`:
the FR-036 `<Entity>Create` / `<Entity>Patch` models, the generated router
(which stamps `dto["createdAt"]`), and the runtime — `ObjectManager`
builds `{_column_of(f): f.name}` on every read and every RETURNING clause,
commented "for cross-port row-shape parity". So one generated module
disagreed with itself about what a field is called.
The read model's stated reason — "the Python model field IS the column, so
it binds straight to the row" — was never true of that runtime, which
hands back field-keyed rows by design. The rationale it shipped under
(#79) was different and narrower: idiomatic snake_case for a Python
consumer, which held only because the example's `@column` happened to be
the snake_case of its field name.
It also leaked a free-form name. `@column` is an arbitrary override, so
`callPurpose` + `@column: purpose_code` emitted a Pydantic field
`purpose_code` — neither the wire name nor anything derived from the field
name, just the DB column surfacing in the API shape.
Idiomatic snake_case is a real goal and this is the wrong lever for it:
`columnNamingStrategy` applied to `field.name` is the right one, and this
port could not select it either. That is the next commit.
The replaced test is rewritten rather than deleted — it pinned the
behaviour, so it has to state the opposite and say why — and its `@column`
is deliberately no longer the snake_case of the field name, since that
coincidence is what made the old behaviour look correct.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NynrRND6ZUwGvq3ZUTCfxG1 parent b8fba15 commit 09b312c
2 files changed
Lines changed: 41 additions & 21 deletions
File tree
- server/python
- src/metaobjects/codegen/generators
- tests/codegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
349 | 356 | | |
350 | 357 | | |
351 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
139 | 150 | | |
140 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | | - | |
144 | 156 | | |
145 | | - | |
146 | | - | |
| 157 | + | |
| 158 | + | |
147 | 159 | | |
148 | 160 | | |
149 | 161 | | |
| |||
301 | 313 | | |
302 | 314 | | |
303 | 315 | | |
304 | | - | |
305 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
306 | 319 | | |
307 | 320 | | |
308 | 321 | | |
| |||
0 commit comments