Skip to content

Commit

Permalink
exposed-java-time test cases are failing for sqlite #954
Browse files Browse the repository at this point in the history
H2 datetime nano precision = 9
  • Loading branch information
Tapac committed Jun 14, 2020
1 parent 8658363 commit 1dce52b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internal object H2DataTypeProvider : DataTypeProvider() {
}

override fun uuidType(): String = "UUID"
override fun dateTimeType(): String = "DATETIME(9)"
}

internal object H2FunctionProvider : FunctionProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import org.jetbrains.exposed.sql.tests.currentDialectTest
import org.jetbrains.exposed.sql.tests.shared.assertEquals
import org.jetbrains.exposed.sql.vendors.MysqlDialect
import org.junit.Test
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneOffset
import java.time.*
import java.time.format.DateTimeFormatter
import java.time.temporal.Temporal
import kotlin.test.assertEquals

Expand Down Expand Up @@ -54,6 +52,12 @@ fun <T:Temporal> assertEqualDateTime(d1: T?, d2: T?) {
assertEquals(d1.toInstant(ZoneOffset.UTC).toEpochMilli() / 1000, d2.toInstant(ZoneOffset.UTC).toEpochMilli() / 1000, "Failed on ${currentDialectTest.name}")
d1 is Instant && d2 is Instant && (currentDialectTest as? MysqlDialect)?.isFractionDateTimeSupported() == false ->
assertEquals(d1.toEpochMilli() / 1000, d2.toEpochMilli() / 1000, "Failed on ${currentDialectTest.name}")
d1 is Instant && d2 is Instant -> assertEquals(d1.toEpochMilli(), d2.toEpochMilli(), "Failed on ${currentDialectTest.name}")
d1 is LocalDateTime && d2 is LocalDateTime -> {
val d1Millis = Instant.from(d1.atZone(ZoneId.systemDefault())).toEpochMilli()
val d2Millis = Instant.from(d2.atZone(ZoneId.systemDefault())).toEpochMilli()
assertEquals(d1Millis, d2Millis, "Failed on ${currentDialectTest.name}")
}
else -> assertEquals(d1, d2, "Failed on ${currentDialectTest.name}")
}
}
Expand Down

0 comments on commit 1dce52b

Please sign in to comment.