diff --git a/exposed-kotlin-datetime/src/main/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinDateColumnType.kt b/exposed-kotlin-datetime/src/main/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinDateColumnType.kt index a238f42f1b..5b80e1dd08 100644 --- a/exposed-kotlin-datetime/src/main/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinDateColumnType.kt +++ b/exposed-kotlin-datetime/src/main/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinDateColumnType.kt @@ -384,6 +384,7 @@ class KotlinDurationColumnType : ColumnType() { } override fun valueFromDB(value: Any): Duration = when (value) { + Duration.INFINITE.inWholeNanoseconds -> Duration.INFINITE is Long -> value.nanoseconds is Number -> value.toLong().nanoseconds is String -> Duration.parse(value) diff --git a/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt b/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt index 7c10f71155..cfa5fb9bc7 100644 --- a/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt +++ b/exposed-kotlin-datetime/src/test/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinTimeTests.kt @@ -26,6 +26,7 @@ import java.time.OffsetDateTime import java.time.ZoneId import java.time.ZoneOffset import kotlin.test.assertEquals +import kotlin.time.Duration open class KotlinTimeBaseTest : DatabaseTestsBase() { @@ -464,6 +465,20 @@ open class KotlinTimeBaseTest : DatabaseTestsBase() { currentDbDateTime() } } + + @Test + fun testInfiniteDuration() { + val tester = object : Table("tester") { + val duration = duration("duration") + } + withTables(tester) { + tester.insert { + it[duration] = Duration.INFINITE + } + val row = tester.selectAll().where { tester.duration eq Duration.INFINITE }.single() + assertEquals(Duration.INFINITE, row[tester.duration]) + } + } } fun assertEqualDateTime(d1: T?, d2: T?) {