Commit f9ed09d
fix(codegen-kotlin): timestamp_with_tz emits Column<Instant> (match Instant data class, drop OffsetDateTime coercion)
The @dbColumnType=timestamp_with_tz opt-in was internally inconsistent for the
Exposed persistence path: the data-class arm emits java.time.Instant, but the
Exposed column arm emitted Exposed's native timestampWithTimeZone(...), which in
Exposed 0.55 is a Column<OffsetDateTime>. The generated table therefore had a
Column<OffsetDateTime> column behind an Instant field, so any
`it[Table.createdAt] = entity.createdAt` (Instant into Column<OffsetDateTime>)
failed to compile — consumers had to hand-coerce Instant<->OffsetDateTime.
Fix: emit a custom Exposed column type that is a Column<java.time.Instant> whose
sqlType() is TIMESTAMP WITH TIME ZONE. It delegates ALL value/JDBC handling
(read, bind, normalize, millisecond-truncate, wire string) to Exposed's tested
JavaInstantColumnType and overrides only sqlType(). This matches the Instant
data class (zero coercion) AND keeps the timezone-aware column, so the
offset->UTC normalization persistence-conformance contract still holds.
Mechanism: native Exposed has no function giving both Column<Instant> and
TIMESTAMP WITH TIME ZONE (timestamp()/JavaInstantColumnType is Column<Instant>
but plain TIMESTAMP; timestampWithTimeZone() is the right DDL but
Column<OffsetDateTime>). The custom delegating type bridges them. The generator
emits the support helper (MetaInstantWithTimeZoneColumnType + a file-local
Table.instantWithTimeZone(name) extension) inline into each table file that has
a timestamp_with_tz column, declared private (file-scoped) so multiple tables in
one package don't clash. No new Exposed dependency is added to any metaobjects
production module.
Data-class type (Instant) and the wire form (Z) are UNCHANGED; the plain
field.timestamp default (datetime/LocalDateTime/no-Z) is UNCHANGED. Kotlin-only:
the Java/TS/Python/C# ports are DTO/string column descriptors with no Exposed
column mismatch and need no change.
Tests/fixtures:
- KotlinTypeMapperTest: timestamp_with_tz now asserts instantWithTimeZone(...) +
null import + Instant data-class type + usesInstantWithTimeZone predicate.
- KotlinExposedTableGeneratorTest: asserts the emitted instantWithTimeZone column,
the file-local support helper, imports, and the TIMESTAMP WITH TIME ZONE DDL.
- integration-tests-kotlin reference AssetTable + sibling
InstantWithTimeZoneColumnType.kt (proves the helper compiles against real
Exposed 0.55), Normalization gains an Instant->UTC+Z branch, QueryScenarioRunner
stops collapsing Instant to LocalDateTime, RuntimeReturnTypeTest asserts
recordedAt is Instant. All run green against Testcontainers Postgres
(QueryScenarioConformanceTest + RuntimeReturnTypeTest), preserving the existing
`timestamp with time zone` DDL + `Z` wire fixtures unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 6c7043e commit f9ed09d
10 files changed
Lines changed: 276 additions & 55 deletions
File tree
- server/java
- codegen-kotlin/src
- main/kotlin/com/metaobjects/generator/kotlin
- test/kotlin/com/metaobjects/generator/kotlin
- integration-tests-kotlin/src/test/kotlin/com/metaobjects/integration/kotlin
- tables
Lines changed: 94 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
| |||
231 | 252 | | |
232 | 253 | | |
233 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
234 | 261 | | |
235 | 262 | | |
236 | 263 | | |
| |||
302 | 329 | | |
303 | 330 | | |
304 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
305 | 343 | | |
306 | 344 | | |
307 | 345 | | |
| |||
402 | 440 | | |
403 | 441 | | |
404 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
405 | 499 | | |
406 | 500 | | |
407 | 501 | | |
| |||
Lines changed: 45 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
| |||
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
104 | 123 | | |
105 | 124 | | |
106 | 125 | | |
| |||
232 | 251 | | |
233 | 252 | | |
234 | 253 | | |
235 | | - | |
236 | | - | |
237 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
238 | 260 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 261 | + | |
| 262 | + | |
243 | 263 | | |
244 | 264 | | |
245 | 265 | | |
| |||
300 | 320 | | |
301 | 321 | | |
302 | 322 | | |
303 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
304 | 327 | | |
305 | | - | |
| 328 | + | |
306 | 329 | | |
307 | 330 | | |
308 | 331 | | |
| |||
334 | 357 | | |
335 | 358 | | |
336 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
337 | 370 | | |
338 | 371 | | |
339 | 372 | | |
| |||
Lines changed: 24 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
712 | | - | |
713 | | - | |
714 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
715 | 719 | | |
716 | | - | |
| 720 | + | |
717 | 721 | | |
718 | 722 | | |
719 | 723 | | |
| |||
731 | 735 | | |
732 | 736 | | |
733 | 737 | | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
738 | 754 | | |
739 | 755 | | |
740 | 756 | | |
| |||
Lines changed: 15 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
166 | 171 | | |
167 | 172 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
| |||
0 commit comments