Skip to content

Fix WHERE fallback, _N field names, and LIKE in aggregates - #39

Merged
rathboma merged 3 commits into
mainfrom
ccr-08e6f61a-sfn73f
Oct 13, 2026
Merged

rathboma merged 3 commits into
mainfrom
ccr-08e6f61a-sfn73f

Conversation

@rathboma

Copy link
Copy Markdown
Contributor
  • Untranslatable WHERE clauses compiled to an empty filter, so UPDATE and
    DELETE with e.g. NOT (...), LOWER(x) = ..., or 1 = 0 hit every document.
    Now NOT (...) and constant conditions are supported and anything else
    throws instead of matching everything.
  • Field names ending in _ (phone_1, address_line_2) were rewritten
    to array paths (phone.1), breaking filters, projections, sorting, and
    making UPDATE write to the wrong field. The parser fallback now uses the
    same unambiguous _ARRAY encoding, so the _N decoding is removed.
  • LIKE in any query compiled to an aggregation pipeline (aliases, nested
    fields, GROUP BY, JOIN) failed with "$regex has to be a string" because
    the executor flattened the RegExp into {}. Non-plain objects are now
    left intact.

Claude-Session: https://claude.ai/code/session_01GFv5U1awSDVVk9HWzCqrpw

- Untranslatable WHERE clauses compiled to an empty filter, so UPDATE and
  DELETE with e.g. NOT (...), LOWER(x) = ..., or 1 = 0 hit every document.
  Now NOT (...) and constant conditions are supported and anything else
  throws instead of matching everything.
- Field names ending in _<number> (phone_1, address_line_2) were rewritten
  to array paths (phone.1), breaking filters, projections, sorting, and
  making UPDATE write to the wrong field. The parser fallback now uses the
  same unambiguous __ARRAY_ encoding, so the _N decoding is removed.
- LIKE in any query compiled to an aggregation pipeline (aliases, nested
  fields, GROUP BY, JOIN) failed with "$regex has to be a string" because
  the executor flattened the RegExp into {}. Non-plain objects are now
  left intact.

Claude-Session: https://claude.ai/code/session_01GFv5U1awSDVVk9HWzCqrpw
- WHERE values that aren't literals (columns, functions, subqueries, casts,
  parameters, arithmetic) were embedded in the filter as raw AST objects.
  With <>, != or NOT IN that matched every document, so e.g.
  DELETE ... WHERE a <> b or WHERE id NOT IN (SELECT ...) wiped the
  collection. These now throw "Unsupported value in WHERE clause".
- UPDATE with JOIN, FROM or multiple tables and DELETE with JOIN or
  multiple tables silently dropped the other tables and their join
  conditions; UPDATE a JOIN b ON ... SET ... ran with no filter at all.
  These now throw instead.

Claude-Session: https://claude.ai/code/session_01GFv5U1awSDVVk9HWzCqrpw
Compiler-level counterparts to regressions.integration.test.ts so these
regressions are caught by yarn test:unit without Docker.

Claude-Session: https://claude.ai/code/session_01GFv5U1awSDVVk9HWzCqrpw
@rathboma
rathboma merged commit 86d641f into main Oct 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant