File tree Expand file tree Collapse file tree
src/main/kotlin/dev/slne/surf/database Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,16 +63,21 @@ public final class dev/slne/surf/database/columns/NativeUuidColumnTypeKt {
6363}
6464
6565public final class dev/slne/surf/database/columns/time/CurrentOffsetDateTime : dev/slne/surf/database/columns/time/CurrentTimestampBase {
66- public static final field INSTANCE Ldev/slne/surf/database/columns/time/CurrentOffsetDateTime;
66+ public fun <init> ()V
67+ public fun <init> (Z)V
68+ public synthetic fun <init> (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
6769}
6870
6971public class dev/slne/surf/database/columns/time/CurrentTimestampBase : org/jetbrains/exposed/v1/core/Function {
70- public fun <init> (Lorg/jetbrains/exposed/v1/core/IColumnType;)V
72+ public fun <init> (Lorg/jetbrains/exposed/v1/core/IColumnType;Z)V
73+ public synthetic fun <init> (Lorg/jetbrains/exposed/v1/core/IColumnType;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
7174 public fun toQueryBuilder (Lorg/jetbrains/exposed/v1/core/QueryBuilder;)V
7275}
7376
7477public final class dev/slne/surf/database/columns/time/CurrentZonedDateTime : dev/slne/surf/database/columns/time/CurrentTimestampBase {
75- public static final field INSTANCE Ldev/slne/surf/database/columns/time/CurrentZonedDateTime;
78+ public fun <init> ()V
79+ public fun <init> (Z)V
80+ public synthetic fun <init> (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
7681}
7782
7883public final class dev/slne/surf/database/columns/time/OffsetDateTimeColumnType : dev/slne/surf/database/columns/time/UtcInstantDateTimeColumnType {
Original file line number Diff line number Diff line change @@ -64,13 +64,4 @@ publishing {
6464 repositories {
6565 slneReleases()
6666 }
67- }
68-
69- afterEvaluate {
70- tasks.named(" publishPluginMavenPublicationToMaven-releasesRepository" ) {
71- enabled = false
72- }
73- tasks.named(" publishPluginMavenPublicationToMavenLocal" ) {
74- enabled = false
75- }
7667}
Original file line number Diff line number Diff line change @@ -3,5 +3,4 @@ kotlin.stdlib.default.dependency=false
33org.gradle.parallel =true
44# org.gradle.caching=true
55# org.gradle.configureondemand=true
6-
7- version =1.0.1-SNAPSHOT
6+ version =1.1.0-SNAPSHOT
Original file line number Diff line number Diff line change @@ -23,5 +23,5 @@ class OffsetDateTimeColumnType :
2323fun Table.offsetDateTime (name : String ): Column <OffsetDateTime > =
2424 registerColumn(name, OffsetDateTimeColumnType ())
2525
26- object CurrentOffsetDateTime :
27- CurrentTimestampBase <OffsetDateTime >(OffsetDateTimeColumnType .INSTANCE )
26+ class CurrentOffsetDateTime ( includeUpdate : Boolean = false ) :
27+ CurrentTimestampBase <OffsetDateTime >(OffsetDateTimeColumnType .INSTANCE , includeUpdate )
Original file line number Diff line number Diff line change @@ -162,11 +162,16 @@ abstract class UtcInstantDateTimeColumnType<T : Any> :
162162 }
163163}
164164
165- open class CurrentTimestampBase <T >(columnType : IColumnType <T & Any >) : Function<T>(columnType) {
165+ open class CurrentTimestampBase <T >(
166+ columnType : IColumnType <T & Any >,
167+ private val includeUpdate : Boolean = false
168+ ) : Function<T>(columnType) {
166169 override fun toQueryBuilder (queryBuilder : QueryBuilder ) = queryBuilder {
167170 + when {
168- (currentDialect as ? MysqlDialect )?.isFractionDateTimeSupported() == true -> " CURRENT_TIMESTAMP(6)"
169- else -> " CURRENT_TIMESTAMP"
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 " " } "
170175 }
171176 }
172177}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dev.slne.surf.database.columns.time
33import org.jetbrains.exposed.v1.core.Column
44import org.jetbrains.exposed.v1.core.Table
55import java.time.Instant
6+ import java.time.OffsetDateTime
67import java.time.ZoneId
78import java.time.ZonedDateTime
89
@@ -23,5 +24,5 @@ class ZonedDateTimeColumnType :
2324fun Table.zonedDateTime (name : String ): Column <ZonedDateTime > =
2425 registerColumn(name, ZonedDateTimeColumnType ())
2526
26- object CurrentZonedDateTime :
27- CurrentTimestampBase <ZonedDateTime >(ZonedDateTimeColumnType .INSTANCE )
27+ class CurrentZonedDateTime ( includeUpdate : Boolean = false ) :
28+ CurrentTimestampBase <ZonedDateTime >(ZonedDateTimeColumnType .INSTANCE , includeUpdate )
Original file line number Diff line number Diff line change 11package dev.slne.surf.database.table
22
3+ import dev.slne.surf.database.columns.time.CurrentOffsetDateTime
4+ import dev.slne.surf.database.columns.time.offsetDateTime
35import org.jetbrains.exposed.v1.core.dao.id.ULongIdTable
4- import org.jetbrains.exposed.v1.javatime.CurrentTimestamp
5- import org.jetbrains.exposed.v1.javatime.timestamp
66
77open class AuditableLongIdTable (name : String = " " ) : ULongIdTable(name) {
8- val createdAt = timestamp (" created_at" )
9- .defaultExpression(CurrentTimestamp )
10- val updatedAt = timestamp (" updated_at" )
11- .defaultExpression(CurrentTimestamp )
8+ val createdAt = offsetDateTime (" created_at" )
9+ .defaultExpression(CurrentOffsetDateTime () )
10+ val updatedAt = offsetDateTime (" updated_at" )
11+ .defaultExpression(CurrentOffsetDateTime ( true ) )
1212}
1313
You can’t perform that action at this time.
0 commit comments