fix: limit number of parameters per delete operation

Splits the list of message UUIDs into smaller chunks to perform batch deletions with a maximum of 500 UUIDs per operation, avoiding `SQLiteException: too many SQL variables (code 1 SQLITE_ERROR)`.

fixes #711
This commit is contained in:
andrekir 2023-09-04 18:17:49 -03:00
parent afce253514
commit ae949ad784

View file

@ -47,7 +47,9 @@ class PacketRepository @Inject constructor(private val packetDaoLazy: dagger.Laz
}
suspend fun deleteMessages(uuidList: List<Long>) = withContext(Dispatchers.IO) {
packetDao.deleteMessages(uuidList)
for (chunk in uuidList.chunked(500)) { // limit number of UUIDs per query
packetDao.deleteMessages(chunk)
}
}
suspend fun deleteWaypoint(id: Int) = withContext(Dispatchers.IO) {