-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00f2b60
commit 293faad
Showing
28 changed files
with
963 additions
and
377 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
allprojects { | ||
group = "org.babyfish.jimmer" | ||
version = "0.8.112" | ||
version = "0.8.113" | ||
} |
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
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
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
113 changes: 113 additions & 0 deletions
113
...t/jimmer-sql-kotlin/src/test/kotlin/org/babyfish/jimmer/sql/kt/mutation/H2MutationTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package org.babyfish.jimmer.sql.kt.mutation | ||
|
||
import org.babyfish.jimmer.kt.new | ||
import org.babyfish.jimmer.sql.ast.mutation.SaveMode | ||
import org.babyfish.jimmer.sql.dialect.H2Dialect | ||
import org.babyfish.jimmer.sql.kt.common.AbstractMutationTest | ||
import org.babyfish.jimmer.sql.kt.model.embedded.Machine | ||
import org.babyfish.jimmer.sql.kt.model.embedded.by | ||
import org.junit.Test | ||
|
||
class H2MutationTest : AbstractMutationTest() { | ||
|
||
@Test | ||
fun testInsertEmbeddedJson() { | ||
connectAndExpect({ | ||
sqlClient { setDialect(H2Dialect()) }.entities.save( | ||
new(Machine::class).by { | ||
id = 10L | ||
detail().apply { | ||
factories = mapOf( | ||
"F-A" to "Factory-A", | ||
"F-B" to "Factory-B" | ||
) | ||
patents = mapOf( | ||
"P-I" to "Patent-I", | ||
"P-II" to "Patent-II" | ||
) | ||
} | ||
}, | ||
con = it | ||
) { | ||
setMode(SaveMode.INSERT_ONLY) | ||
}.totalAffectedRowCount to sqlClient.entities.forConnection(it).findById( | ||
Machine::class, | ||
10L | ||
) | ||
}) { | ||
statement { | ||
sql( | ||
"""insert into MACHINE(ID, factory_map, patent_map) | ||
|values(?, ? format json, ? format json)""".trimMargin() | ||
) | ||
} | ||
statement { | ||
sql( | ||
"""select tb_1_.ID, tb_1_.factory_map, tb_1_.patent_map from MACHINE tb_1_ where tb_1_.ID = ?""".trimMargin() | ||
) | ||
} | ||
value( | ||
"""( | ||
|--->1, | ||
|--->{ | ||
|--->--->"id":10, | ||
|--->--->"detail":{ | ||
|--->--->--->"factories":{"F-A":"Factory-A","F-B":"Factory-B"}, | ||
|--->--->--->"patents":{"P-I":"Patent-I","P-II":"Patent-II"} | ||
|--->--->} | ||
|--->} | ||
|)""".trimMargin() | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun testUpdateEmbeddedJson() { | ||
connectAndExpect({ | ||
sqlClient { setDialect(H2Dialect()) }.entities.save( | ||
new(Machine::class).by { | ||
id = 1L | ||
detail().apply { | ||
patents = mapOf( | ||
"P-I" to "Patent-I", | ||
"P-II" to "Patent-II" | ||
) | ||
} | ||
}, | ||
con = it | ||
) { | ||
setMode(SaveMode.UPDATE_ONLY) | ||
}.totalAffectedRowCount to sqlClient.entities.forConnection(it).findById( | ||
Machine::class, | ||
1L | ||
) | ||
}) { | ||
statement { | ||
sql( | ||
"""update MACHINE | ||
|set patent_map = ? format json | ||
|where ID = ?""".trimMargin() | ||
) | ||
} | ||
statement { | ||
sql( | ||
"""select tb_1_.ID, tb_1_.factory_map, tb_1_.patent_map | ||
|from MACHINE tb_1_ | ||
|where tb_1_.ID = ?""".trimMargin() | ||
) | ||
} | ||
value( | ||
"""( | ||
|--->1, | ||
|--->{ | ||
|--->--->"id":1, | ||
|--->--->"detail":{ | ||
|--->--->--->"factories":{"f-1":"factory-1","f-2":"factory-2"}, | ||
|--->--->--->"patents":{"P-I":"Patent-I","P-II":"Patent-II"} | ||
|--->--->} | ||
|--->} | ||
|)""".trimMargin() | ||
) | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
project/jimmer-sql-kotlin/src/test/kotlin/org/babyfish/jimmer/sql/kt/query/EmbeddedTest.kt
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
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
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
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
93 changes: 51 additions & 42 deletions
93
project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/Variables.java
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
Oops, something went wrong.