File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/test/kotlin/examples/kotlin/mybatis3/joins Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,41 @@ class ExistsTest {
164
164
}
165
165
}
166
166
167
+ @Test
168
+ fun testPropagateTableAliasToExists () {
169
+ newSession().use { session ->
170
+ val mapper = session.getMapper(CommonSelectMapper ::class .java)
171
+
172
+ val selectStatement = select(itemMaster.allColumns()) {
173
+ from(itemMaster, " im" )
174
+ where {
175
+ not {
176
+ exists {
177
+ select(orderLine.allColumns()) {
178
+ from(orderLine, " ol" )
179
+ where { orderLine.itemId isEqualTo itemMaster.itemId }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ orderBy(itemMaster.itemId)
185
+ }
186
+
187
+ val expectedStatement: String = " select im.* from ItemMaster im" +
188
+ " where not exists (select ol.* from OrderLine ol where ol.item_id = im.item_id)" +
189
+ " order by item_id"
190
+ assertThat(selectStatement.selectStatement).isEqualTo(expectedStatement)
191
+
192
+ val rows = mapper.selectManyMappedRows(selectStatement)
193
+ assertThat(rows).hasSize(1 )
194
+
195
+ with (rows[0 ]) {
196
+ assertThat(this ).containsEntry(" ITEM_ID" , 55 )
197
+ assertThat(this ).containsEntry(" DESCRIPTION" , " Catcher Glove" )
198
+ }
199
+ }
200
+ }
201
+
167
202
@Test
168
203
fun testAndExists () {
169
204
newSession().use { session ->
You can’t perform that action at this time.
0 commit comments