Skip to content
Source
Sign inSign up
TanStack/db

fix(db): terminate nested predicate subtraction #1777

ClosedKyleAMathews(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromcodex/predicate-recursion-overflowopened

Showing 4 changed files with 41 additions and 32 deletions (loading 2).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/fix-nested-predicate-subtraction.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/db': patch
+---
+​
+Ensure predicate subtraction terminates when common conditions are nested inside conjunctions.
36 additions and 32 deletionspackages/db/src/query/predicate-utils.tsModified
View file
@@ -404,21 +404,25 @@
if (commonConditions.length > 0) {
// Extract predicates without common conditions
- const fromWithoutCommon = removeConditions(fromPredicate, commonConditions)
- const subtractWithoutCommon = removeConditions(
+ const fromRemoval = removeConditions(fromPredicate, commonConditions)
+ const subtractRemoval = removeConditions(
subtractPredicate,
commonConditions,
​
- // Recursively compute difference on simplified predicates
- const simplifiedDifference = minusWherePredicates(
- fromWithoutCommon,
- subtractWithoutCommon,
- )