Commit da7ee92
fix(codegen-kotlin): snake_case column names + uuid/timestamp type overrides
KotlinExposedTableGenerator was emitting Exposed column declarations
with the YAML field name verbatim as the column-name string argument,
producing varchar("displayName", ...) when Postgres convention is
snake_case (display_name). Downstream adopters whose schema follows
that convention hit "column does not exist" at query time.
Also: field.timestamp defaulted to timestampWithTimeZone which is
the rarer Postgres variant; many schemas use plain timestamp. And
there was no way to declare a varchar field as a Postgres uuid column.
Fixes:
- camelToSnake helper converts column-name argument (Kotlin property
name stays camelCase; only the SQL column string is snake_case'd)
- field.string + @dbColumnType=uuid -> Exposed uuid(...) column type
(Kotlin property stays String; Exposed coerces at the SQL boundary)
- field.timestamp default -> plain timestamp(...) (not timestampWithTimeZone)
- field.timestamp + @dbColumnType=timestamp_with_tz -> opts in to TZ-aware
Snake-case conversion is applied uniformly across all column-emission
paths: regular field columns, enumerationByName columns, flattened
object sub-columns, jsonb columns, declared FK columns (from
relationship.composition), inferred FK columns (from inverse many-side),
and identity.reference-decorated columns.
Regression tests cover each: camelToSnake helper unit tests
(8 cases incl. acronyms, digits, idempotency), per-column-emission
path tests, and an opt-in timestampWithTimeZone test. Snapshot
fixtures updated where they exercised the affected default mappings
(4 snapshots: bidirectional-fk PostTable, fk PostTable, view
SalesReportTable, primitives AuthorTable).
Tests: 104 pass (up from 98; added 6 new tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 695d1f3 commit da7ee92
10 files changed
Lines changed: 375 additions & 52 deletions
File tree
- server/java/codegen-kotlin/src
- main/kotlin/com/metaobjects/generator/kotlin
- test
- kotlin/com/metaobjects/generator/kotlin
- resources/snapshots
- entity-with-bidirectional-fk/acme/blog
- entity-with-fk/acme/blog
- entity-with-view/acme/report
- single-entity-primitives/acme/demo
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
| 202 | + | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
| 205 | + | |
| 206 | + | |
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| |||
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
280 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
| |||
286 | 291 | | |
287 | 292 | | |
288 | 293 | | |
289 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
| |||
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
| 451 | + | |
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
447 | | - | |
| 455 | + | |
448 | 456 | | |
449 | 457 | | |
450 | 458 | | |
| |||
467 | 475 | | |
468 | 476 | | |
469 | 477 | | |
| 478 | + | |
470 | 479 | | |
471 | 480 | | |
472 | 481 | | |
473 | | - | |
| 482 | + | |
474 | 483 | | |
475 | 484 | | |
476 | 485 | | |
| |||
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
49 | 88 | | |
Lines changed: 78 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
62 | 84 | | |
63 | 85 | | |
64 | 86 | | |
| |||
110 | 132 | | |
111 | 133 | | |
112 | 134 | | |
113 | | - | |
114 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
115 | 145 | | |
116 | 146 | | |
117 | 147 | | |
| |||
130 | 160 | | |
131 | 161 | | |
132 | 162 | | |
133 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
134 | 172 | | |
135 | 173 | | |
136 | 174 | | |
| |||
144 | 182 | | |
145 | 183 | | |
146 | 184 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
155 | 201 | | |
156 | 202 | | |
157 | 203 | | |
158 | 204 | | |
159 | 205 | | |
160 | 206 | | |
161 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
162 | 214 | | |
163 | 215 | | |
164 | 216 | | |
| |||
174 | 226 | | |
175 | 227 | | |
176 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
177 | 243 | | |
178 | 244 | | |
179 | 245 | | |
| |||
0 commit comments