From 8f1ce8ecb1f657364704287574c193b0e7778229 Mon Sep 17 00:00:00 2001 From: BoD Date: Mon, 9 Dec 2024 17:45:23 +0100 Subject: [PATCH] Account for the maximum number of variables in SQLite --- .../cache/normalized/sql/SqlNormalizedCache.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/normalized-cache-sqlite-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt b/normalized-cache-sqlite-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt index e9ae2a70..8ad54c21 100644 --- a/normalized-cache-sqlite-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt +++ b/normalized-cache-sqlite-incubating/src/commonMain/kotlin/com/apollographql/cache/normalized/sql/SqlNormalizedCache.kt @@ -137,8 +137,10 @@ class SqlNormalizedCache internal constructor( } else { emptySet() } - recordDatabase.delete(keys + referencedKeys) - return recordDatabase.changes().toInt() + return (keys + referencedKeys).chunked(999).sumOf { chunkedKeys -> + recordDatabase.delete(chunkedKeys) + recordDatabase.changes().toInt() + } } /**