diff --git a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt index 34852fb4..babeffaf 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt @@ -647,6 +647,10 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore: val filteredCandidates = if (!list.allItems) { val items = db.checkInListQueries.selectItemIdsForList(list.id) .executeAsList() + .map { + // Not-null assertion needed for SQLite + it.id!! + } .toHashSet() candidates.filter { candidate -> val candidateItem = db.itemQueries.selectById(candidate.itemId).executeAsOne() @@ -978,7 +982,13 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore: ).executeAsOneOrNull() ?: throw CheckException("Check-in list not found") val itemIds = if (!list.all_items) { - db.checkInListQueries.selectItemIdsForList(list.id).executeAsList().ifEmpty { null } + db.checkInListQueries.selectItemIdsForList(list.id) + .executeAsList() + .map { + // Not-null assertion needed for SQLite + it.id!! + } + .ifEmpty { null } } else { null } @@ -1137,7 +1147,12 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore: } if (!list.allItems) { - val product_ids = db.checkInListQueries.selectItemIdsForList(list.id).executeAsList() + val product_ids = db.checkInListQueries.selectItemIdsForList(list.id) + .executeAsList() + .map { + // Not-null assertion needed for SQLite + it.id!! + } lq = lq.and(OrderPosition.ITEM_ID.`in`(product_ids)) } diff --git a/libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/CheckInList.sq b/libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/CheckInList.sq index bfbf78c8..d0bbefc7 100644 --- a/libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/CheckInList.sq +++ b/libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/CheckInList.sq @@ -80,7 +80,9 @@ DELETE FROM CheckInList_Item WHERE CheckInListId = :checkin_list_id; selectItemIdsForList: -SELECT ItemId +-- We must select at least two columns, otherwise we get different result types between +-- SQLite and Postgres since the ItemId column is only defined as NOT NULL in Postgres +SELECT ItemId AS id, CheckInListId FROM CheckInList_Item WHERE CheckInListId = :checkin_list_id;