Commit 8352079
* feat(python-codegen): @column field naming, server-default exprs, --entities allowlist
Three consumer-facing gaps surfaced by generating Python record models from the SAME
entity metadata that drives the TypeScript Drizzle layer:
1. @column-aware Pydantic field naming. The entity/value generator emitted `field.name`
verbatim, so a model authored camelCase for the TS port (`callPurpose` +
`@column: call_purpose`) produced camelCase Python fields that don't match the DB
columns. The Pydantic field name is now `@column` when present, else `field.name` —
one entity feeds both languages idiomatically (camelCase TS property, snake_case
Python field = the physical column). Backward-compatible: no @column emits identically.
2. Server-side default EXPRESSIONS are no longer rendered as Python literal defaults.
A string @default matching the SQL-expression patterns (now, now(),
current_timestamp/date/time, anything ending in `()` such as gen_random_uuid()) is
DB-filled, so emitting `id: uuid.UUID = "gen_random_uuid()"` was wrong. Such a field
now carries no Python default (keeps its required/optional shape); literal defaults
(bool/int/str/enum) are unchanged. Mirrors the TS column-mapper's SQL_EXPR_PATTERNS
so both ports agree on what counts as an expression.
3. `metaobjects gen --entities <names>` allowlist. The whole model is still loaded (so
`extends` bases and @objectref VOs resolve), but only the named entities are emitted
— generate a subset of a shared model without splitting the metadata. Wired through
`gen` and `verify --codegen` (run_gen already supported entity_filter).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(release): bump python port to 0.12.0
Minor bump for the backward-compatible codegen features in the previous commit
(@column field naming, server-default expressions, --entities allowlist) and to
align the Python port with the 0.12.x line. pyproject + uv.lock self-version only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9b56002 commit 8352079
6 files changed
Lines changed: 155 additions & 11 deletions
File tree
- server/python
- src/metaobjects
- codegen/generators
- tests/codegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
132 | 141 | | |
133 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
137 | 149 | | |
138 | | - | |
139 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
140 | 156 | | |
141 | 157 | | |
142 | 158 | | |
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
146 | | - | |
| 162 | + | |
147 | 163 | | |
148 | 164 | | |
149 | 165 | | |
| |||
277 | 293 | | |
278 | 294 | | |
279 | 295 | | |
280 | | - | |
| 296 | + | |
| 297 | + | |
281 | 298 | | |
282 | 299 | | |
283 | 300 | | |
| |||
317 | 334 | | |
318 | 335 | | |
319 | 336 | | |
320 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
321 | 340 | | |
322 | | - | |
| 341 | + | |
| 342 | + | |
323 | 343 | | |
324 | 344 | | |
325 | 345 | | |
| |||
566 | 586 | | |
567 | 587 | | |
568 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
569 | 598 | | |
570 | 599 | | |
571 | 600 | | |
| |||
638 | 667 | | |
639 | 668 | | |
640 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
641 | 675 | | |
642 | 676 | | |
643 | 677 | | |
| |||
Lines changed: 34 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
28 | 51 | | |
29 | 52 | | |
30 | 53 | | |
| |||
121 | 144 | | |
122 | 145 | | |
123 | 146 | | |
124 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
125 | 151 | | |
126 | 152 | | |
127 | 153 | | |
| |||
154 | 180 | | |
155 | 181 | | |
156 | 182 | | |
157 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
158 | 190 | | |
159 | 191 | | |
160 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
42 | 66 | | |
43 | 67 | | |
44 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
77 | 131 | | |
78 | 132 | | |
79 | 133 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments