File tree Expand file tree Collapse file tree
src/main/kotlin/dev/slne/surf/database/columns/time Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ kotlin.stdlib.default.dependency=false
33org.gradle.parallel =true
44# org.gradle.caching=true
55# org.gradle.configureondemand=true
6- version =2.0.2
6+ version =2.0.3
Original file line number Diff line number Diff line change @@ -167,11 +167,24 @@ open class CurrentTimestampBase<T>(
167167 private val includeUpdate : Boolean = false
168168) : Function<T>(columnType) {
169169 override fun toQueryBuilder (queryBuilder : QueryBuilder ) = queryBuilder {
170- + when {
171- (currentDialect as ? MysqlDialect )?.isFractionDateTimeSupported() == true -> " CURRENT_TIMESTAMP(6) ${
172- if (includeUpdate) " ON UPDATE CURRENT_TIMESTAMP(6)" else " "
173- } "
174- else -> " CURRENT_TIMESTAMP ${if (includeUpdate) " ON UPDATE CURRENT_TIMESTAMP" else " " } "
170+ + when (val dialect = currentDialect) {
171+ // Postgres' CURRENT_TIMESTAMP is a `timestamp with time zone`. The column is stored as
172+ // `timestamp without time zone` holding UTC wall-clock values (see notNullValueToDB), so
173+ // convert to UTC to keep the DB default consistent with application-written instants.
174+ // Postgres has no inline `ON UPDATE` (that requires a trigger), so includeUpdate is not
175+ // expressible here and is intentionally ignored to keep the generated DDL valid.
176+ is PostgreSQLDialect ->
177+ " (CURRENT_TIMESTAMP AT TIME ZONE 'UTC')"
178+
179+ else -> {
180+ val current =
181+ if ((dialect as ? MysqlDialect )?.isFractionDateTimeSupported() == true )
182+ " CURRENT_TIMESTAMP(6)"
183+ else
184+ " CURRENT_TIMESTAMP"
185+
186+ if (includeUpdate) " $current ON UPDATE $current " else current
187+ }
175188 }
176189 }
177190}
You can’t perform that action at this time.
0 commit comments