Skip to content

fix: keep nested OR groups as OR inside an OR array - #110

Merged
ytkimirti merged 9 commits into
DX-3147-qb-and-orfrom
DX-3147-qb-or-nest
Nov 24, 2026
Merged

ytkimirti merged 9 commits into
DX-3147-qb-and-orfrom
DX-3147-qb-or-nest

Conversation

@ytkimirti

Copy link
Copy Markdown
Collaborator

Bug: In the Query Builder, an OR group nested inside an OR group returns documents matching all of its conditions instead of any of them. Inside an $or array, a same-operator child group was merged into one plain object like { name: "a", status: "b" }, and the fields of a plain object are always ANDed.
Fix: Only merge a child group into a plain object when both it and its parent are AND groups.

Why each change

  • components/databrowser/components/ui-query-builder/query-stringify.ts: the merge is only an equivalent rewrite for AND ($and: [{ $and: { a, b } }] is $and: [{ a, b }]); for OR, the child keeps its $or wrapper.
  • components/databrowser/components/ui-query-builder/query-roundtrip.test.ts: locks in that a nested $or stays $or inside an $or array, and that a nested $and inside an $and array is still merged.

Repro: In the Query Builder, switch the root to OR, add a nested OR group with conditions on name and status, and a condition on active: the Code Editor shows $or: [{ name: ..., status: ... }, { active: ... }], so only documents matching both name and status (or active) are returned.

Part of DX-3147

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-redis-browser Ready Ready Preview Nov 17, 2026 4:30pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 15, 2026

Copy link
Copy Markdown

DX-3147

@ytkimirti
ytkimirti marked this pull request as ready for review October 22, 2026 11:33
@ytkimirti
ytkimirti added this pull request to stack #118 October 28, 2026 07:55
@ytkimirti
ytkimirti merged commit 9cea9f8 into master Nov 24, 2026
5 checks passed
@ytkimirti
ytkimirti deleted the DX-3147-qb-or-nest branch November 24, 2026 10:14

This branch was successfully deployed

1 active deployment
Preview — de90d867 Deployed Nov 17, 2026 by vercel[bot]
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.

2 participants