You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix isWhereSubset to handle AND subset with OR superset (#1275)
* fix(db): fix isNull predicate causing LiveQuery to never become ready when offline
The `isWhereSubsetInternal` function had a critical ordering issue in its
predicate checking logic. When a query with `and(eq(...), isNull(...))` was
checked against a union superset like `or(and(eq(...), isNull(...)), ...)`,
the AND decomposition ran before the OR superset check. This caused the
function to decompose the AND into individual conjuncts (eq and isNull),
neither of which could independently prove subset of the OR expression,
even though the full AND expression was structurally equal to one of the
OR disjuncts.
The fix reorders the checks so that:
1. superset AND is handled first (unchanged)
2. subset OR is handled next (moved up from after AND)
3. superset OR is handled next (moved up from after IN)
4. subset AND decomposition happens last
This ensures that when subset=AND and superset=OR, the full AND expression
is checked against each OR disjunct (where structural equality catches it),
before being decomposed into individual conjuncts that lose the ability to
match compound disjuncts.
Reported scenario: on-demand sync with `isNull(soft_deleted_at)` in a where
clause caused `isLoadingSubset` to stay true after going offline and
remounting, because the DeduplicatedLoadSubset couldn't recognize that
data for the predicate was already loaded.
https://claude.ai/code/session_01TmGem9Pj1NnXfaWY5FZJdb
* ci: apply automated fixes
* refactor: improve error handling and test coverage for review feedback
Separate forceDisconnectAndRefresh into its own try-catch with correct
error attribution, add negative guard test for isUpToDate check, add
rejection path test, trim verbose comments, and clarify wording.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: add changeset for isNull predicate fix
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: handle forceDisconnectAndRefresh PauseLock error gracefully
When loadSubset is called during subscriber message processing (e.g.,
join pipelines via D2.step), the stream's PauseLock is held and
forceDisconnectAndRefresh deadlocks. Since the refresh is only an
optimization to break out of long-poll waits, log the error and fall
through to requestSnapshot which still works.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Fix isNull predicate causing LiveQuery to never become ready when offline. Reorder predicate checks in `isWhereSubsetInternal` so OR superset handling runs before AND subset decomposition, allowing `and(eq, isNull)` to match structurally equal disjuncts. Also separate `forceDisconnectAndRefresh` error handling into its own try-catch with correct error attribution.
0 commit comments