diff --git a/.changeset/33792-cross-object-orphan-native.md b/.changeset/33792-cross-object-orphan-native.md index db571968c9c..0329fdd4e28 100644 --- a/.changeset/33792-cross-object-orphan-native.md +++ b/.changeset/33792-cross-object-orphan-native.md @@ -11,8 +11,8 @@ Metadata-protocol: none **BREAKING** for a reader of an analytics answer served by the native SQL strategy (a cube or dataset query with no bucketed time dimension, on a SQL datasource) that reads a related object's field through a relationship path (`'order.status'`) in any of the three filter positions one compile serves: the query's `where`, a measure's own `filter` (its conditional aggregate) and the dataset's own `filter`: -- FROM: a detail row whose relation field is empty, or names no existing record, was selected by `$ne`, `$nin`, `$notContains`, `$null: true`, `$eq: null`, `$exists: false` and `$empty: true` on the related field, because the `LEFT JOIN` read every related column of such a row as NULL. So the same widget answered a different total once a time bucket sent it to the engine path. TO: such a leaf is evaluated on an existing parent (the last hop's `id = id` is conjoined to it, through every hop of the path: TRUE for an existing parent, UNKNOWN for none, so a `$not` cannot flip it), and outside `$not` no such row is selected by those operators. Under `$not` the native answer is the one it gave before. The native, engine and `/data` answers agree on those operators. +- FROM: a detail row whose relation field is empty, or names no existing record, was selected by `$ne`, `$nin`, `$notContains`, `$null: true`, `$eq: null`, `$exists: false` and `$empty: true` on the related field, because the `LEFT JOIN` read every related column of such a row as NULL. So the same widget answered a different total once a time bucket sent it to the engine path. TO: such a leaf is evaluated on an existing parent (the last hop's `id = id` is conjoined to it, through every hop of the path: TRUE for an existing parent, UNKNOWN for none, so a `$not` cannot flip it), and outside `$not` no such row is selected by those operators. Under one `$not` the native answer is the one it gave before. Under two, `{ $not: { $not: { 'order.status': { $null: true } } } }`, the two negations now cancel and the answer is the un-negated condition's, so such a row is no longer selected there either, where it was before. The native, engine and `/data` answers agree on those operators. -**Not moved.** A parent that exists with no value in the field still satisfies `$ne`, `$nin`, `$notContains` and `$null: true`. A positive operator (`$eq` a value, `$in`, `$gt`, `$contains`, …) selected no such row before either, and its statement is unchanged. A leaf on the base relation field itself (`{ order: { $null: true } }`) reads no join and is unchanged. Two native-path answers still select such a row, unchanged by this release: a positive comparison under `$not` (`{ $not: { 'order.status': 'open' } }`, a shape the engine path refuses; write `$ne` / `$nin` inside the condition instead), and `$nin: []`, which folds to the constant TRUE and selects every row, where the engine path leaves such rows out. +**Not moved.** A parent that exists with no value in the field still satisfies `$ne`, `$nin`, `$notContains` and `$null: true`. A positive operator (`$eq` a value, `$in`, `$gt`, `$contains`, …) selected no such row before either, and its statement is unchanged. A leaf on the base relation field itself (`{ order: { $null: true } }`) reads no join and is unchanged. One native-path answer still selects such a row, unchanged by this release: under one `$not`, any condition a missing value does not satisfy, such as a comparison with a value (`{ $not: { 'order.status': 'open' } }`) or a presence test (`$null: false`, `$exists: true`, `$ne: null`, `$empty: false`), a shape the engine path refuses; write `$ne` / `$nin` inside the condition instead. The fix for an author who wants the rows with an empty relation: OR the base relation field in, `{ $or: [{ 'order.status': { $ne: 'open' } }, { order: { $null: true } }] }`. A row naming a record that no longer exists is not brought back by it, on either path. diff --git a/.changeset/34384-empty-nin-related-field.md b/.changeset/34384-empty-nin-related-field.md new file mode 100644 index 00000000000..e1ca38807d4 --- /dev/null +++ b/.changeset/34384-empty-nin-related-field.md @@ -0,0 +1,19 @@ +--- +'@objectstack/service-analytics': patch +--- + +fix(service-analytics)!: on the native SQL strategy, an empty `$nin` on a related field no longer selects a detail row with no parent, as on the engine path and `/data` + +Clause-②: no (narrowing) +Metadata-protocol: none + + + +**BREAKING** for a reader of an analytics answer served by the native SQL strategy (a cube or dataset query with no bucketed time dimension, on a SQL datasource) whose filter reads a related object's field through a relationship path with an empty list, `{ 'order.status': { $nin: [] } }`, in any of the three filter positions one compile serves: the query's `where`, a measure's own `filter` and the dataset's own `filter`: + +- FROM: the empty `$nin` folded to the constant TRUE (`1 = 1`), so it selected every detail row, including one whose relation field is empty or names no existing record. The same widget answered a different total once a time bucket sent it to the engine path, which leaves such rows out. +- TO: it is evaluated on an existing parent, like every other operator on a related field: the last hop's `id = id` (TRUE for an existing parent, UNKNOWN for none) takes the place of the constant, through every hop of the path. It selects every detail row whose related record exists, including one whose field has no value. The native, engine and `/data` answers agree. + +**Not moved.** An empty `$nin` on the queried object's own field is still the constant TRUE, and its statement is unchanged. An empty `$in` selects no row on either path, as before. Under `$not` an empty `$nin` on a related field selected no row and still selects none. + +The fix for an author who wants the rows with an empty relation: OR the base relation field in, `{ $or: [{ 'order.status': { $nin: [] } }, { order: { $null: true } }] }`. A row naming a record that no longer exists is not brought back by it, on either path. diff --git a/content/docs/ui/dashboards.mdx b/content/docs/ui/dashboards.mdx index 84a7c580a77..8d93028432a 100644 --- a/content/docs/ui/dashboards.mdx +++ b/content/docs/ui/dashboards.mdx @@ -548,7 +548,7 @@ evaluates it on one of two paths, and the path decides how deep it may reach: | Path | When it serves the query | Depth | | :--- | :--- | :--- | | Native SQL | A SQL datasource (SQLite, PostgreSQL, MySQL, SQL Server, Turso), unless the query buckets a date by granularity, reads a federated object, or reads an object with an engine-enforced read gate (an engine middleware, or a `controlled_by_parent` read scope) | Every hop, as a `LEFT JOIN` per relationship | -| Engine aggregate | Every query the native SQL path does not serve | One relationship | +| Engine aggregate | Every query the native SQL path does not serve | Up to three relationships (ADR-0071's hop limit), each read as the caller | On the engine-aggregate path the filter reads the related object **as the caller**, with that object's row-level security and field permissions, and keeps @@ -562,12 +562,19 @@ the base rows whose relationship points at a record it returned: unfiltered set. - A related field the caller cannot read is refused (`403 PERMISSION_DENIED`), as filtering on it directly would be. -- More than 1,000 matching related records are refused (`400 INVALID_FILTER`), - never truncated. Narrow the related condition. +- On a SQL datasource the related condition runs inside the same statement, as + a subquery, so the number of matching related records is not limited. Where + the engine reads the matching related ids first instead (a related object on + another datasource, a federated one, or a driver that compiles no subquery, + such as MongoDB; the full list is in + [Query Syntax](/docs/protocol/objectql/query-syntax)), more than 1,000 of them + are refused (`400 INVALID_FILTER`), never truncated. Narrow the related + condition. - These are refused (`400 INVALID_FIELD`) rather than answered differently: a - path of two or more relationships (`line.plan.order.status`), a related-field - condition under `$not` (write `$ne` / `$nin` inside the condition instead), and - a related field compared with another field (`$field`). + path of four or more relationships (`line.plan.order.customer.tier`), a + related-field condition under `$not` (write `$ne` / `$nin` inside the + condition instead), and a related field compared with another field + (`$field`). On the native SQL path, too, a related-field condition that is not under `$not` never selects a row with no related record (an empty relationship, or @@ -577,16 +584,21 @@ filter, a measure's own `filter` or the dataset's own `filter`: `$ne`, `$nin`, included, so the two paths agree on such rows. The same `$or` brings back the rows with an empty relationship on both paths; a row naming a record that no longer exists is not brought back by it. A related record that exists with no -value in the field still satisfies `$ne` and `$nin`. Two native-path exceptions -remain: under `$not`, which the engine path refuses, the native path still -selects such a row when the negated condition is a comparison with a value -(`{ $not: { 'order.status': 'open' } }`), so write `$ne` / `$nin` inside the -condition instead; and `$nin: []` (an empty list) selects every row on the -native path, such rows included, where the engine path leaves them out. - -A related field in a **dataset's own** `filter`, or in a **measure's** own -`filter`, is still evaluated only on the native SQL path; the engine-aggregate -path refuses it (`400 INVALID_FIELD`) rather than count rows it cannot join. +value in the field still satisfies `$ne` and `$nin`, and `$nin: []` (an empty +list, which excludes no value) selects every row whose related record exists. +One native-path exception remains, under `$not`, which the engine path refuses: +the native path still selects such a row when the negated condition is one a +missing value does not satisfy, such as a comparison with a value +(`{ $not: { 'order.status': 'open' } }`) or a presence test (`$null: false`, +`$exists: true`, `$ne: null`, `$empty: false`), so write `$ne` / `$nin` inside +the condition instead. Two `$not`s cancel: `{ $not: { $not: CONDITION } }` +selects exactly the rows `CONDITION` selects, so it leaves such a row out +wherever `CONDITION` does. + +A related field in a **dataset's own** `filter` is evaluated on both paths, as +in the query's filter. A related field in a **measure's** own `filter` is still +evaluated only on the native SQL path; the engine-aggregate path refuses it +(`400 INVALID_FIELD`) rather than count rows it cannot join. ### Date Filter Defaults diff --git a/packages/services/service-analytics/src/__tests__/cross-object-negative-orphan.test.ts b/packages/services/service-analytics/src/__tests__/cross-object-negative-orphan.test.ts index d1381d1b274..54798763c6f 100644 --- a/packages/services/service-analytics/src/__tests__/cross-object-negative-orphan.test.ts +++ b/packages/services/service-analytics/src/__tests__/cross-object-negative-orphan.test.ts @@ -4,9 +4,10 @@ * A cross-object leaf (`'order.status'`, and through two hops) never selects a * detail row that has no parent — on the native SQL strategy as on the engine path and * the `/data` nested-relation filter — outside `$not`, for every operator pinned - * below. Two native answers still select one and are not pinned here: a - * positive comparison under `$not` (the engine refuses the shape) and - * `$nin: []`, which folds to the constant TRUE. + * below, `$nin: []` included (#34384). One native answer still selects one and + * is not pinned here: under `$not`, a condition a missing value does not + * satisfy (`{ $not: { 'order.status': 'open' } }`, `$null: false`; the engine + * refuses the shape). * * ## What was wrong * @@ -178,6 +179,8 @@ describe('a cross-object leaf never selects an orphan detail row, on the native ['$empty true', { 'order.status': { $empty: true } }, { order: { status: { $empty: true } } }, ['l6']], ['$exists false', { 'order.status': { $exists: false } }, { order: { status: { $exists: false } } }, ['l6']], ["$ne 'cancelled'", { 'order.status': { $ne: 'cancelled' } }, { order: { status: { $ne: 'cancelled' } } }, ['l1', 'l2', 'l6']], + // An empty `$nin` excludes no value, so it selects every line whose order exists, and no orphan. + ['$nin []', { 'order.status': { $nin: [] } }, { order: { status: { $nin: [] } } }, ['l1', 'l2', 'l3', 'l4', 'l5', 'l6']], // A positive operator never selected an orphan: the comparison is UNKNOWN on a NULL. Unchanged. ["$eq 'cancelled'", { 'order.status': { $eq: 'cancelled' } }, { order: { status: { $eq: 'cancelled' } } }, ['l3', 'l4', 'l5']], ]; @@ -198,6 +201,7 @@ describe('a cross-object leaf never selects an orphan detail row, on the native const TWO_HOP: Array<[string, Record, Record, string[]]> = [ ["$ne 'gold'", { 'order.customer.tier': { $ne: 'gold' } }, { order: { customer: { tier: { $ne: 'gold' } } } }, ['l3', 'l4', 'l5']], ['$null true', { 'order.customer.tier': { $null: true } }, { order: { customer: { tier: { $null: true } } } }, []], + ['$nin []', { 'order.customer.tier': { $nin: [] } }, { order: { customer: { tier: { $nin: [] } } } }, ['l1', 'l2', 'l3', 'l4', 'l5']], ]; for (const [label, where, nested, expected] of TWO_HOP) { it(`order.customer.tier ${label}: native, engine and /data select the same lines`, async () => { @@ -260,6 +264,8 @@ describe('a cross-object leaf never selects an orphan detail row, on the native ['$not $and [$null true, amount < 2000]', { $not: { $and: [{ 'order.status': { $null: true } }, { amount: { $lt: 2000 } }] } }, ['l1', 'l2', 'l3', 'l4', 'l5', 'l8']], // Two hops, the last hop's key. ['$not two-hop $null true', { $not: { 'order.customer.tier': { $null: true } } }, ['l1', 'l2', 'l3', 'l4', 'l5']], + // An empty `$nin` negated: no line, before and now. + ['$not $nin []', { $not: { 'order.status': { $nin: [] } } }, []], ]; for (const [label, where, expected] of NEGATED) { it(`native, ${label}: the answer it gave before the conjunct`, async () => { @@ -301,4 +307,59 @@ describe('a cross-object leaf never selects an orphan detail row, on the native expect(await totals('native', { $not: { 'order.status': { $null: true } } })) .toEqual(await totals('native', { 'order.status': { $null: false } })); }); + + // Two `$not`s over a leaf a NULL satisfies cancel: the conjunct makes the + // leaf UNKNOWN for an orphan, and `NOT (NOT UNKNOWN)` is UNKNOWN, so the + // answer is the un-negated leaf's. On `origin/main` `5a755791a9`, before the + // conjunct, the inner `NOT` was FALSE for an orphan and the outer one TRUE, + // so both orphans were selected (3 / 6300). The engine path refuses the shape + // (`negated`), so this is the native face alone. + it('native: `$not` over `$not` over `$null: true` answers what `$null: true` answers', async () => { + const twice = await totals('native', { $not: { $not: { 'order.status': { $null: true } } } }); + expect(twice).toEqual({ n: 1, total: sumOf(['l6']) }); + expect(twice).toEqual(await totals('native', { 'order.status': { $null: true } })); + }); + + // [#34384] `$nin: []` lowers to the NULL escape around a constant TRUE. On a + // joined member that TRUE is evaluated on an existing parent too, as every + // other leaf a NULL satisfies is; on a base column it stays the constant. + it('native: an empty `$nin` on a joined member is the last hop key, on a base column the constant TRUE', async () => { + const joined = await services.native!.generateSql({ cube: LINE, measures: ['count'], where: { 'order.status': { $nin: [] } } } as never); + expect(joined.sql).toContain('LEFT JOIN "os33792_order" "order" ON'); + expect(joined.sql).toContain('(("order"."status" IS NULL AND "order"."id" = "order"."id") OR "order"."id" = "order"."id")'); + expect(joined.sql).not.toContain('1 = 1'); + + const twoHop = await services.native!.generateSql({ cube: LINE, measures: ['count'], where: { 'order.customer.tier': { $nin: [] } } } as never); + expect(twoHop.sql).toContain('OR "order__customer"."id" = "order__customer"."id")'); + + const base = await services.native!.generateSql({ cube: LINE, measures: ['count'], where: { amount: { $nin: [] } } } as never); + expect(base.sql).not.toContain('JOIN'); + expect(base.sql).toContain('1 = 1'); + }); + + it("an empty `$nin` in a measure's own filter: native leaves the orphan out, the engine refuses it as every related field there", async () => { + const scoped = DatasetSchema.parse({ + ...DATASET, + name: 'os34384_lines_measure_filter_empty_nin', + measures: [ + { name: 'line_count', aggregate: 'count', filter: { 'order.status': { $nin: [] } } }, + { name: 'total', aggregate: 'sum', field: 'amount' }, + ], + }); + const res = await services.native!.queryDataset(scoped, { measures: ['line_count'] } as never); + const [row] = res.rows as Array>; + expect(Number(row?.line_count)).toBe(6); + await expect(services.objectql!.queryDataset(scoped, { measures: ['line_count'] } as never)) + .rejects.toMatchObject({ code: 'INVALID_FIELD', status: 400 }); + }); + + it("an empty `$nin` in the dataset's own filter leaves the orphan out, native and engine alike", async () => { + const scoped = DatasetSchema.parse({ ...DATASET, name: 'os34384_lines_dataset_filter_empty_nin', filter: { 'order.status': { $nin: [] } } }); + const expected = ['l1', 'l2', 'l3', 'l4', 'l5', 'l6']; + for (const face of ['native', 'objectql'] as const) { + const res = await services[face]!.queryDataset(scoped, { measures: ['line_count', 'total'] } as never); + const [row] = res.rows as Array>; + expect.soft({ n: Number(row?.line_count ?? 0), total: Number(row?.total ?? 0) }, face).toEqual({ n: expected.length, total: sumOf(expected) }); + } + }); }); diff --git a/packages/services/service-analytics/src/__tests__/where-equality-slot-list-refusal.test.ts b/packages/services/service-analytics/src/__tests__/where-equality-slot-list-refusal.test.ts index 221834b8db8..f6c355f07e7 100644 --- a/packages/services/service-analytics/src/__tests__/where-equality-slot-list-refusal.test.ts +++ b/packages/services/service-analytics/src/__tests__/where-equality-slot-list-refusal.test.ts @@ -185,7 +185,9 @@ describe('[#19888] the neighbouring shapes compile exactly as before', () => { ['the empty $in — the FALSE constant', { stage: { $in: [] } }, { kind: 'const', value: false }], // [ADR-0053 D-D1, amended — #5930 step 3] The TRUE constant, inside the // shared lowering's NULL escape (`$nin` is negative-polarity): TRUE still. - ['the empty $nin — the TRUE constant', { stage: { $nin: [] } }, { kind: 'or', children: [leaf('stage', 'notSet', []), { kind: 'const', value: true }] }], + // [#34384] It names the member it was written on, so the native compile can + // evaluate it on an existing parent when that member is a related field. + ['the empty $nin — the TRUE constant', { stage: { $nin: [] } }, { kind: 'or', children: [leaf('stage', 'notSet', []), { kind: 'const', value: true, member: 'stage' }] }], // [#20887] Accepted, and carried as written for the engine (it used to flatten to `acct.region`). ['a nested-relation scalar', { acct: { region: 'NA' } }, { kind: 'relation', member: 'acct', condition: { region: 'NA' } }], ['a field reference under $eq (served on the engine path)', { amount: { $eq: { $field: 'budget' } } }, leaf('amount', 'equals', [{ $field: 'budget' }])], diff --git a/packages/services/service-analytics/src/__tests__/where-face-arms-refusal.test.ts b/packages/services/service-analytics/src/__tests__/where-face-arms-refusal.test.ts index a91c3387282..f1221546703 100644 --- a/packages/services/service-analytics/src/__tests__/where-face-arms-refusal.test.ts +++ b/packages/services/service-analytics/src/__tests__/where-face-arms-refusal.test.ts @@ -257,7 +257,9 @@ describe('[#20010] the neighbouring shapes compile exactly as before', () => { ['the empty $in — the FALSE constant', { stage: { $in: [] } }, { kind: 'const', value: false }], // [ADR-0053 D-D1, amended — #5930 step 3] The TRUE constant, inside the // shared lowering's NULL escape (`$nin` is negative-polarity): TRUE still. - ['the empty $nin — the TRUE constant', { stage: { $nin: [] } }, { kind: 'or', children: [leaf('stage', 'notSet', []), { kind: 'const', value: true }] }], + // [#34384] It names the member it was written on, so the native compile can + // evaluate it on an existing parent when that member is a related field. + ['the empty $nin — the TRUE constant', { stage: { $nin: [] } }, { kind: 'or', children: [leaf('stage', 'notSet', []), { kind: 'const', value: true, member: 'stage' }] }], ['a scalar ordering comparand', { amt: { $gt: 5 } }, leaf('amt', 'gt', [5])], ['a { $field } in an ordering slot (served on the engine path)', { amt: { $gt: { $field: 'id' } } }, leaf('amt', 'gt', [{ $field: 'id' }])], ['the implicit null — the has-no-value predicate', { stage: null }, leaf('stage', 'notSet', [])], diff --git a/packages/services/service-analytics/src/strategies/filter-normalizer.ts b/packages/services/service-analytics/src/strategies/filter-normalizer.ts index 7ff23441235..51b6146d686 100644 --- a/packages/services/service-analytics/src/strategies/filter-normalizer.ts +++ b/packages/services/service-analytics/src/strategies/filter-normalizer.ts @@ -619,7 +619,20 @@ function comparand(v: unknown): unknown { */ export type NormalizedFilterNode = | { kind: 'leaf'; member: string; operator: string; values: unknown[] } - | { kind: 'const'; value: boolean } + /** + * [#34384] `member` is set on ONE constant: the TRUE an empty `$nin` folds to. + * It names the field the author wrote the leaf on, because that TRUE is still + * a condition on that field: on a member the native compile reads through a + * relationship path it holds only for a row whose parent exists ("no parent + * never matches, whatever the operator", `cross-object-where.ts`). The member + * gates need no second reading of it: the shared lowering wraps every `$nin` + * in the NULL escape (`{ $or: [{ f: { $null: true } }, { f: { $nin: [] } }] }`), + * so the escape's `notSet` leaf names the same member beside it (see + * {@link collectFilterLeaves}), and a `$not` never meets the constant bare + * ({@link notOf} receives the escape's `$or`). Every other constant names no + * member. + */ + | { kind: 'const'; value: boolean; member?: string } | { kind: 'and'; children: NormalizedFilterNode[] } | { kind: 'or'; children: NormalizedFilterNode[] } | { kind: 'not'; child: NormalizedFilterNode } @@ -1251,8 +1264,14 @@ function fieldLeaves(key: string, raw: unknown): NormalizedFilterNode[] { // NULL-safe `$not` rewrite below to stay correct: a dropped conjunct // inside a negation flips the whole negation's answer, while `1 = 0` // negates to `1 = 1` the way `read-scope-sql.ts` already has it. + // + // [#34384] The empty `$nin`'s TRUE keeps the member it was written on + // (see the `const` row of {@link NormalizedFilterNode}): folded to a bare + // TRUE, a related field's `$nin: []` selected the detail rows with no + // parent on the native path, which no other operator does. The empty + // `$in`'s FALSE selects no row, parent or not, and names nothing. if ((opKey === '$in' || opKey === '$nin') && Array.isArray(wrapper[opKey]) && (wrapper[opKey] as unknown[]).length === 0) { - out.push({ kind: 'const', value: opKey === '$nin' }); + out.push(opKey === '$nin' ? { kind: 'const', value: true, member: key } : { kind: 'const', value: false }); continue; } @@ -2480,7 +2499,10 @@ export function collectFilterLeaves( // it are the engine's to judge, as the caller, when it reads that object. if (node.kind === 'relation') return [{ member: node.member, operator: 'relation', values: [] }]; // A boolean constant names no member — it constrains rows, not columns — so - // it contributes nothing to the cross-object envelope check. + // it contributes nothing to the cross-object envelope check. The empty + // `$nin`'s TRUE names its member too, and is not read here: the shared + // lowering wraps every `$nin` in its NULL escape, whose `notSet` leaf names + // the same member, so every gate already reads that member for it. if (node.kind === 'const') return []; if (node.kind === 'not') return collectFilterLeaves(node.child); return node.children.flatMap(collectFilterLeaves); diff --git a/packages/services/service-analytics/src/strategies/native-sql-strategy.ts b/packages/services/service-analytics/src/strategies/native-sql-strategy.ts index 37ce29eca26..8c01a168639 100644 --- a/packages/services/service-analytics/src/strategies/native-sql-strategy.ts +++ b/packages/services/service-analytics/src/strategies/native-sql-strategy.ts @@ -2214,6 +2214,19 @@ export class NativeSQLStrategy implements AnalyticsStrategy { if (!node) return null; if (node.kind === 'const') { + // [#34384] The empty `$nin`'s TRUE names the member it was written on. On + // a joined member it is a leaf a NULL satisfies like the others the leaf + // arm below guards, so it is evaluated on an existing parent the same + // way: the last hop's `key = key`, TRUE for an existing parent and + // UNKNOWN for none. As the bare `1 = 1` it selected the orphans the + // engine path and `/data` leave out (`cross-object-where.ts`: no parent + // never matches, whatever the operator). On a base column, or an + // expression, the constant is the answer. It binds nothing. + if (node.value && node.member !== undefined) { + this.resolveFieldSql(cube, node.member, parentTable, joins); + const parentKey = this.joinedParentKey(cube, node.member, parentTable, joins); + if (parentKey) return `${parentKey} = ${parentKey}`; + } return node.value ? SQL_CONST_TRUE : SQL_CONST_FALSE; }