Created
March 15, 2018 07:38
-
-
Save Tapac/2518c19cbeefc6be6e56cfa850ed18db to your computer and use it in GitHub Desktop.
Test for defaultExpression with updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun testDefaultExpressions02() { | |
val foo = object : IntIdTable("foo") { | |
val name = text("name") | |
val defaultDateTime = datetime("defaultDateTime").defaultExpression(CurrentDateTime()) | |
} | |
val nonDefaultDate = DateTime.parse("2000-01-01") | |
withTables(foo) { | |
val id = foo.insertAndGetId { | |
it[foo.name] = "bar" | |
it[foo.defaultDateTime] = nonDefaultDate | |
} | |
val result = foo.select { foo.id eq id }.single() | |
assertEquals("bar", result[foo.name]) | |
assertEquals(nonDefaultDate.millis, result[foo.defaultDateTime].withTimeAtStartOfDay().millis) | |
foo.update({foo.id eq id}) { | |
it[foo.name] = "baz" | |
} | |
val result2 = foo.select { foo.id eq id }.single() | |
assertEquals("baz", result2[foo.name]) | |
assertEquals(nonDefaultDate, result2[foo.defaultDateTime].withTimeAtStartOfDay()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment