Mybatis kotlin dynamic sql update to newest 1.5.0 trouble with isIn
mikebski opened this issue · 3 comments
NOTE - Cross posted to SO and I'll update whichever one when I get the answer: https://stackoverflow.com/questions/78347769/mybatis-kotlin-dynamic-sql-update-to-newest-1-5-0-trouble-with-isin
I'm converting a couple of pieces of code to the newest mybatis dynamic sql, and this line is giving me fits:
** Old Code - won't compile with newest version **
fencingSupportMapper.select { where(facility, isIn(*searchData.selectedFacilities!!)) }
** New Code (not working but compiles) **
val fencingForFacilities: List = fencingSupportMapper.select { where { facility isIn { searchData.selectedFacilities } }
My error is You must specify a select statement in a sub query
Now, my searchData.selectedFacilities is a list of Int values (and the facility column for the WHERE is an int.
Can someone see what's wrong? I've looked at the docs and don't see what's going on here...
Of course, 5 minutes after posting this I figured it out -
fencingSupportMapper.select { where { facility.isIn(*searchData.selectedFacilities!!) } }
@mikebski Of course, it always happens that way! Sometimes is that extra effort to post the issue or get someone else attention that sparks your own resolution. Glad you figured it out!
@mikebski you could also code it like this (using the infix function and avoiding the spread operator):
fencingSupportMapper.select { where { facility isIn searchData.selectedFacilities!!.asList() } }I'll add some functions that accept Arrays too, so it will look more natural