Skip to content

Commit

Permalink
test changed properties for nested binding
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jul 8, 2024
1 parent 56638d6 commit 5fdd30e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ktorm-core/src/test/kotlin/org/ktorm/entity/EntityTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,29 @@ class EntityTest : BaseTest() {
assert(p2.flushChanges() == 1)
}

@Test
fun testChangedPropertiesForNestedBinding1() {
val p1 = database.sequenceOf(Parents).find { it.id eq 1 } ?: throw AssertionError()
p1.child?.grandChild?.job = "Senior Engineer"
p1.child?.grandChild?.job = "Expert Engineer"

assert(p1.changedProperties.size == 1)
assert(p1.changedProperties["child"].toString() == "Child(grandChild=GrandChild(job=engineer))")
assert(p1.flushChanges() == 1)
}

@Test
fun testChangedPropertiesForNestedBinding2() {
val p2 = database.sequenceOf(Parents).find { it.id eq 1 } ?: throw AssertionError()
p2.child?.grandChild?.name = "Vincent"
p2.child?.grandChild?.job = "Senior Engineer"
p2.child?.grandChild?.job = "Expert Engineer"

assert(p2.changedProperties.size == 1)
assert(p2.changedProperties["child"].toString() == "Child(grandChild=GrandChild(name=vince, job=engineer))")
assert(p2.flushChanges() == 1)
}

@Test
fun testHasColumnValue() {
val p1 = Parent()
Expand Down

0 comments on commit 5fdd30e

Please sign in to comment.