Skip to content

Commit 7281e22

Browse files
committed
Failing test for gh-437
1 parent 440be15 commit 7281e22

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/test/kotlin/examples/kotlin/mybatis3/joins/ExistsTest.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,41 @@ class ExistsTest {
164164
}
165165
}
166166

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+
167202
@Test
168203
fun testAndExists() {
169204
newSession().use { session ->

0 commit comments

Comments
 (0)