Skip to content

Commit 02125ed

Browse files
committed
Merge branch 'feat/wave2-jvm' into feat/wave2-timestamp
2 parents 3f2e388 + 62acfd2 commit 02125ed

26 files changed

Lines changed: 389 additions & 222 deletions

File tree

server/java/codegen-kotlin/src/main/kotlin/com/metaobjects/generator/kotlin/KotlinExposedTableGenerator.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
5656
val fkMap = buildGlobalFkMap(loader, refDecorationMap)
5757

5858
// Packages that emit at least one table carrying a
59-
// `@dbColumnType=timestamp_with_tz` column. Each such package gets ONE
59+
// instant (default, non-`@localTime`) column. Each such package gets ONE
6060
// shared `MetaInstantWithTimeZoneColumnType.kt` support file (emitted in
6161
// pass 3 below) instead of inlining the helper into every table file —
62-
// multiple timestamp_with_tz tables in one package would otherwise
62+
// multiple instant-timestamp tables in one package would otherwise
6363
// redeclare the top-level support class/extension and fail to compile.
6464
val packagesNeedingInstantTzHelper = sortedSetOf<String>()
6565

@@ -103,7 +103,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
103103
}
104104

105105
// Pass 3: emit ONE shared `MetaInstantWithTimeZoneColumnType.kt` per package
106-
// that has at least one `@dbColumnType=timestamp_with_tz` column. The helper
106+
// that has at least one instant (default, non-`@localTime`) column. The helper
107107
// (custom `ColumnType<Instant>` + `Table.instantWithTimeZone(...)` extension) is
108108
// `internal`, so every `*Table.kt` in the same package + module shares the single
109109
// declaration with no redeclaration / private-access clash.
@@ -114,7 +114,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
114114

115115
/**
116116
* Emit the per-package `MetaInstantWithTimeZoneColumnType.kt` support file for
117-
* `@dbColumnType=timestamp_with_tz` columns: an `internal` custom `ColumnType<Instant>`
117+
* instant (default, non-`@localTime`) columns: an `internal` custom `ColumnType<Instant>`
118118
* (DDL `TIMESTAMP WITH TIME ZONE`) plus the `internal Table.instantWithTimeZone(name)`
119119
* column-builder extension that the generated table files call. `internal` keeps it
120120
* package+module-private (no leakage) while letting EVERY `*Table.kt` in the package use
@@ -150,7 +150,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
150150

151151
/**
152152
* Emit one `*Table.kt` for [entity]. Returns `true` when the table carries at
153-
* least one `@dbColumnType=timestamp_with_tz` column — the caller uses that to
153+
* least one instant (default, non-`@localTime`) column — the caller uses that to
154154
* record the package as needing the shared `MetaInstantWithTimeZoneColumnType.kt`
155155
* support file (emitted once per package, not per table).
156156
*/
@@ -226,7 +226,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
226226
objectColumns.any { it.kind == ObjectColumnKind.JSONB } || hasStringJsonbOpenBag
227227
val needsRefOptForDecor = refDecorations.values.any { it.hasReferenceOption }
228228

229-
// Does any column on this table use the TZ-aware `@dbColumnType=timestamp_with_tz`
229+
// Does any column on this table use the TZ-aware instant (default, non-`@localTime`)
230230
// opt-in? If so the table calls the `instantWithTimeZone(...)` column-builder
231231
// extension, which lives in the package-shared `MetaInstantWithTimeZoneColumnType.kt`
232232
// support file (emitted once per package — see emitInstantTzSupportFile). The
@@ -331,7 +331,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
331331
append("import org.jetbrains.exposed.sql.CustomFunction\n")
332332
append("import org.jetbrains.exposed.sql.UUIDColumnType\n")
333333
}
334-
// @dbColumnType=timestamp_with_tz calls the `instantWithTimeZone(...)` extension
334+
// an instant (default) timestamp calls the `instantWithTimeZone(...)` extension
335335
// from the package-shared MetaInstantWithTimeZoneColumnType.kt support file. That
336336
// extension is `internal` + same-package, so the table file needs NO import for it
337337
// and NO Instant/Column imports (the column's `Column<Instant>` type is inferred).
@@ -430,11 +430,11 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
430430
append(" }\n")
431431
}
432432
append("}\n")
433-
// NOTE: the `@dbColumnType=timestamp_with_tz` support helper
433+
// NOTE: the instant (default, non-`@localTime`) support helper
434434
// (MetaInstantWithTimeZoneColumnType + instantWithTimeZone extension) is NO LONGER
435435
// inlined here. It is emitted ONCE PER PACKAGE as a shared internal
436436
// MetaInstantWithTimeZoneColumnType.kt file (see emitInstantTzSupportFile), so
437-
// multiple timestamp_with_tz tables in one package don't redeclare it.
437+
// multiple instant-timestamp tables in one package don't redeclare it.
438438
}
439439

440440
val outFile = outRoot.resolve(pkg.replace('.', '/')).resolve("$tableObjectName.kt")
@@ -552,7 +552,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
552552

553553
/**
554554
* File name (sans `.kt`) of the per-package shared support file emitted for
555-
* `@dbColumnType=timestamp_with_tz` columns. One per package that has ≥1 such column.
555+
* instant (default, non-`@localTime`) columns. One per package that has ≥1 such column.
556556
*/
557557
const val INSTANT_TZ_SUPPORT_FILE_NAME = "MetaInstantWithTimeZoneColumnType"
558558

@@ -573,7 +573,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
573573

574574
/**
575575
* Shared support body emitted ONCE PER PACKAGE (into [INSTANT_TZ_SUPPORT_FILE_NAME].kt)
576-
* for any package that has at least one `@dbColumnType=timestamp_with_tz` column. Defines:
576+
* for any package that has at least one instant (default, non-`@localTime`) column. Defines:
577577
*
578578
* - `MetaInstantWithTimeZoneColumnType` — a `ColumnType<Instant>` that delegates ALL
579579
* value/JDBC handling (read, bind, normalize, millisecond-truncate, wire string) to
@@ -586,15 +586,15 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
586586
* tables call (`val createdAt = instantWithTimeZone("created_at")`).
587587
*
588588
* Both are declared `internal` (package + module-private) so EVERY `*Table.kt` in the
589-
* same package shares the ONE declaration — multiple timestamp_with_tz tables per
589+
* same package shares the ONE declaration — multiple instant-timestamp tables per
590590
* package no longer redeclare a top-level class/extension (the bug the prior per-file
591591
* inline emission caused). Note: the `$` lines below have no Kotlin string templates,
592592
* so this trimMargin block is emitted verbatim.
593593
*/
594594
val INSTANT_TZ_SUPPORT_BLOCK: String = """
595595
|/**
596596
| * GENERATED — do not hand-edit.
597-
| * Custom Exposed column type for `@dbColumnType=timestamp_with_tz`: a
597+
| * Custom Exposed column type for instant (default, non-`@localTime`): a
598598
| * `Column<java.time.Instant>` whose SQL DDL is `TIMESTAMP WITH TIME ZONE`.
599599
| * Delegates all value/JDBC handling to Exposed's `JavaInstantColumnType` and
600600
| * overrides only `sqlType()`, so the column type matches the `Instant` data-class
@@ -621,7 +621,7 @@ open class KotlinExposedTableGenerator : MultiFileDirectGeneratorBase<MetaObject
621621
|}
622622
|
623623
|/**
624-
| * Column builder for `@dbColumnType=timestamp_with_tz`: a `Column<Instant>` backed by
624+
| * Column builder for instant (default, non-`@localTime`): a `Column<Instant>` backed by
625625
| * a `TIMESTAMP WITH TIME ZONE` Postgres column (see [MetaInstantWithTimeZoneColumnType]).
626626
| */
627627
|internal fun Table.instantWithTimeZone(name: String): Column<Instant> =

0 commit comments

Comments
 (0)