JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.05k stars 674 forks source link

fix: EXPOSED-366 inList with EntityID column causes type mismatch error #2070

Closed bog-walk closed 2 months ago

bog-walk commented 2 months ago

Since 0.50.0, attempting to use a valid iterable of comparables with inList() invoked by an EntityID column leads to a type mismatch. This happens because the following incorrect overload is being resolved:

infix fun <T> ExpressionWithColumnType<T>.inList(list: Iterable<T>): InListOrNotInListBaseOp<T> = SingleValueInListOp(this, list, isInList = true)

instead of the previous expected overload that wraps values as EntityIDs:

infix fun <T : Comparable<T>> Column<EntityID<T>?>.inList(list: Iterable<T>): InListOrNotInListBaseOp<EntityID<T>?> {
    val idTable = (columnType as EntityIDColumnType<T>).idColumn.table as IdTable<T>
    return SingleValueInListOp(this, list.map { EntityIDFunctionProvider.createEntityID(it, idTable) }, isInList = true)
}

This reverts the change, and also for notInList().