Repository navigation
Conversation
StasDoskalenko
added a commit
to StasDoskalenko/NitromelonDB
that referenced
this pull request
Sep 24, 2026
…ted Q.on) canEncodeMatcher rejected only sql/loki conditions. A Q.on nested inside Q.and/Q.or still reached the matcher and threw "Illegal Q.on". Mirror encodeWhere() instead: only where, and and/or made entirely of them, are matchable in JS; everything else re-fetches. Approach from Nozbe#1977. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StasDoskalenko
added a commit
to StasDoskalenko/NitromelonDB
that referenced
this pull request
Sep 25, 2026
…erveOrNull; sortBy with unsafeSqlExpr (#141) * fix(observation): observe queries with raw SQL/Loki expressions; add findAndObserveOrNull and Q.sortBy(Q.unsafeSqlExpr()) - canEncodeMatcher now rejects Q.unsafeSqlExpr / Q.unsafeLokiExpr anywhere in the where tree, so those queries re-run on change instead of throwing "Illegal clause sql" from the JS matcher (WatermelonDB#1679) - Collection#findAndObserveOrNull(id): emits null for a missing record, the record once it appears, and null again once it's deleted - Q.sortBy accepts Q.unsafeSqlExpr() on SQLite adapters; LokiJS rejects it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(observation): allow-list JS-matchable conditions (also covers nested Q.on) canEncodeMatcher rejected only sql/loki conditions. A Q.on nested inside Q.and/Q.or still reached the matcher and threw "Illegal Q.on". Mirror encodeWhere() instead: only where, and and/or made entirely of them, are matchable in JS; everything else re-fetches. Approach from Nozbe#1977. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, these queries are wrongly reported as encodable:
Q.unsafeSqlExpr(...)Q.unsafeLokiExpr(...)Q.on(...)nested insideQ.and/Q.orand they result in throwing
Illegal clause …/Illegal Q.on found …byencodeMatcher.Fix
isEncodableWhere, which follows the same branches asencodeWhere:whereis encodable,and/orare encodable if all their conditions are, and anything else is not.canEncodeMatchernow also requires every top-levelwherecondition to pass this check, so these queries fall back to reloading observation.forbiddenErrorto mentionQ.unsafeSqlExprandQ.unsafeLokiExpr.