From 64c5d80c6cc58d624cd77747eb6cf4d3cef5f6ce Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 09:56:19 +0000 Subject: [PATCH 1/5] test(service-analytics): WIP pin for svc.query/generateSql json-column refusal Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude --- .../dataset-json-column-refusal-36168.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts index 2dc91b744bc..872c664ce8f 100644 --- a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts +++ b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts @@ -354,3 +354,44 @@ describe('[#36168] NativeSQLStrategy: refused on every named dialect, declined o expect({ raw, aggregates }).toEqual({ raw: 0, aggregates: 1 }); }); }); + +// ───────────────────────────────────────────────────────────────────────────── + +describe('[#36264] svc.query and svc.generateSql refuse it too, on a named dialect', () => { + const CUBE = { + name: OBJECT, + sql: OBJECT, + measures: { cnt: { label: 'Count', type: 'count', sql: '*' } }, + dimensions: { seen: { label: 'Seen', type: 'time', sql: 'seen' } }, + public: true, + } as unknown as Cube; + const SHAPES: Record = { + tags: { type: 'select', multiple: true }, + seen: { type: 'datetime', multiple: true }, + }; + const svc = new AnalyticsService({ + cubes: [CUBE], + logger: quiet, + sourceFieldMeta: (object: string, field: string) => (object === OBJECT ? SHAPES[field] : undefined), + sqlDialect: () => 'postgres', + hasObjectMiddleware: () => false, + queryCapabilities: () => ({ nativeSql: true, objectqlAggregate: false, inMemory: false }), + executeRawSql: async () => [], + } as never); + const ask = (door: 'query' | 'generateSql', extra: Partial) => + svc[door]({ cube: OBJECT, measures: ['cnt'], ...extra } as AnalyticsQuery); + + for (const door of ['query', 'generateSql'] as const) { + it(`${door}: \$in on a multiple: true field → 400 INVALID_FILTER; CONTROL: \$contains answers`, async () => { + const err = await refusalOf(ask(door, { where: { tags: { $in: ['a'] } } })); + expect(err.code, err.message).toBe('INVALID_FILTER'); + expect(err.status).toBe(400); + await expect(ask(door, { where: { tags: { $contains: 'a' } } })).resolves.toBeDefined(); + }); + } + + it('PROBE dateRange', async () => { + const err = await refusalOf(ask('query', { timeDimensions: [{ dimension: 'seen', dateRange: ['2026-01-01', '2026-02-01'] }] })); + expect(err.message).toBe('x'); + }); +}); From d164ccf63df79e7d77b9cfb3bf947b696dfaa568 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 10:07:20 +0000 Subject: [PATCH 2/5] test(service-analytics): pin the json-column refusal on svc.query and svc.generateSql; widen the changeset's BREAKING declaration Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude --- .changeset/36168-dataset-json-column-refusal.md | 8 ++++---- .../__tests__/dataset-json-column-refusal-36168.test.ts | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.changeset/36168-dataset-json-column-refusal.md b/.changeset/36168-dataset-json-column-refusal.md index edcfa3d3c88..8e4685f1982 100644 --- a/.changeset/36168-dataset-json-column-refusal.md +++ b/.changeset/36168-dataset-json-column-refusal.md @@ -2,14 +2,14 @@ '@objectstack/service-analytics': patch --- -fix(service-analytics)!: the dataset query door refuses `=`, `$in` and every other scalar comparison or text operator on a multi-value or JSON field with the data door's `400 INVALID_FILTER`, instead of answering a wrong count +fix(service-analytics)!: the dataset query door, `POST /api/v1/analytics/query` and the native arm of `POST /api/v1/analytics/sql` refuse `=`, `$in` and every other scalar comparison or text operator on a multi-value or JSON field with the data door's `400 INVALID_FILTER`, instead of answering a wrong count -Clause-②: no (narrowing) +Clause-②: no (narrowing) — the dataset query door, `POST /api/v1/analytics/query` and the native SQL arm of `POST /api/v1/analytics/sql` refuse a scalar comparison on a multi-value or JSON field, in a `where` or a `timeDimensions[].dateRange` window, that they answered `200` Metadata-protocol: none - + -**BREAKING** for a client of `POST /api/v1/analytics/dataset/query` (and every other caller of the dataset query on the native SQL strategy or the draft preview) whose `runtimeFilter`, dataset `filter` or measure `filter` applies an operator of `JSON_COLUMN_INCOMPATIBLE_OPERATORS` (`@objectstack/core`) — `$eq` or implicit equality, `$ne`, `$in`, `$nin`, `$gt` / `$gte` / `$lt` / `$lte`, `$between`, `$startsWith`, `$endsWith`, `$icontains` — to a field declared `multiple: true`, an inherently multi-value type (`tags`, `multiselect`, `checkboxes`) or a structured-JSON type: +**BREAKING** for a client of `POST /api/v1/analytics/dataset/query` (and every other caller of the dataset query on the native SQL strategy or the draft preview) whose `runtimeFilter`, dataset `filter` or measure `filter` applies, and for a client of `POST /api/v1/analytics/query` or of `POST /api/v1/analytics/sql` answered by the native SQL strategy whose `where` applies — or whose `timeDimensions[].dateRange` window (a `$gte` / `$lte` pair) applies — an operator of `JSON_COLUMN_INCOMPATIBLE_OPERATORS` (`@objectstack/core`) — `$eq` or implicit equality, `$ne`, `$in`, `$nin`, `$gt` / `$gte` / `$lt` / `$lte`, `$between`, `$startsWith`, `$endsWith`, `$icontains` — to a field declared `multiple: true`, an inherently multi-value type (`tags`, `multiselect`, `checkboxes`) or a structured-JSON type: - FROM: the native SQL strategy compared the stored JSON text (`["a","b"]`) against the comparand and answered `200`: `$in` / `$eq` counted no row, `$nin` / `$ne` counted the rows they were asked to exclude, and the orderings and the text operators matched the serialization. The draft preview (`?preview=draft`) gave the same counts over the drafted rows. TO: `400 INVALID_FILTER` before anything runs, in the words `POST /api/v1/data/:object/query` answers, naming the field and the operator, on every dialect. The ObjectQL strategy already answered this. On a datasource whose SQL dialect the host cannot name (memory, MongoDB), the native strategy now declines such a query, so the engine answers it through its own driver. diff --git a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts index 872c664ce8f..b858855383e 100644 --- a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts +++ b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts @@ -367,7 +367,7 @@ describe('[#36264] svc.query and svc.generateSql refuse it too, on a named diale } as unknown as Cube; const SHAPES: Record = { tags: { type: 'select', multiple: true }, - seen: { type: 'datetime', multiple: true }, + seen: { type: 'tags' }, }; const svc = new AnalyticsService({ cubes: [CUBE], @@ -390,8 +390,9 @@ describe('[#36264] svc.query and svc.generateSql refuse it too, on a named diale }); } - it('PROBE dateRange', async () => { + it('query: a timeDimensions dateRange on such a member → 400 INVALID_FILTER (its window is a $gte / $lte filter)', async () => { const err = await refusalOf(ask('query', { timeDimensions: [{ dimension: 'seen', dateRange: ['2026-01-01', '2026-02-01'] }] })); - expect(err.message).toBe('x'); + expect(err.code, err.message).toBe('INVALID_FILTER'); + expect(err.status).toBe(400); }); }); From e48453e08b5be4e010248f76080a58e06ba7dfc2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 11:55:28 +0000 Subject: [PATCH 3/5] fix(service-analytics): changeset scopes the unknown-dialect decline to where/filters; window pinned on both doors Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude --- .changeset/36168-dataset-json-column-refusal.md | 4 ++-- .../dataset-json-column-refusal-36168.test.ts | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.changeset/36168-dataset-json-column-refusal.md b/.changeset/36168-dataset-json-column-refusal.md index 8e4685f1982..fa0768ef01e 100644 --- a/.changeset/36168-dataset-json-column-refusal.md +++ b/.changeset/36168-dataset-json-column-refusal.md @@ -9,9 +9,9 @@ Metadata-protocol: none -**BREAKING** for a client of `POST /api/v1/analytics/dataset/query` (and every other caller of the dataset query on the native SQL strategy or the draft preview) whose `runtimeFilter`, dataset `filter` or measure `filter` applies, and for a client of `POST /api/v1/analytics/query` or of `POST /api/v1/analytics/sql` answered by the native SQL strategy whose `where` applies — or whose `timeDimensions[].dateRange` window (a `$gte` / `$lte` pair) applies — an operator of `JSON_COLUMN_INCOMPATIBLE_OPERATORS` (`@objectstack/core`) — `$eq` or implicit equality, `$ne`, `$in`, `$nin`, `$gt` / `$gte` / `$lt` / `$lte`, `$between`, `$startsWith`, `$endsWith`, `$icontains` — to a field declared `multiple: true`, an inherently multi-value type (`tags`, `multiselect`, `checkboxes`) or a structured-JSON type: +**BREAKING** for a client of `POST /api/v1/analytics/dataset/query` (and every other caller of the dataset query on the native SQL strategy or the draft preview) whose `runtimeFilter`, dataset `filter` or measure `filter`, and for a client of `POST /api/v1/analytics/query` or of `POST /api/v1/analytics/sql` answered by the native SQL strategy whose `where`, applies an operator of `JSON_COLUMN_INCOMPATIBLE_OPERATORS` (`@objectstack/core`) — `$eq` or implicit equality, `$ne`, `$in`, `$nin`, `$gt` / `$gte` / `$lt` / `$lte`, `$between`, `$startsWith`, `$endsWith`, `$icontains` — to a multi-value or JSON field: an inherently multi-value type (`tags`, `multiselect`, `checkboxes`), a `select`, `radio`, `lookup`, `user`, `file` or `image` field declared `multiple: true`, or a structured-JSON type. The same holds on all three doors, when the native SQL strategy answers, for a `timeDimensions[].dateRange` window on such a field (the dataset door's `selection.timeDimensions[]` included), which compiles to a `$gte` / `$lte` pair: -- FROM: the native SQL strategy compared the stored JSON text (`["a","b"]`) against the comparand and answered `200`: `$in` / `$eq` counted no row, `$nin` / `$ne` counted the rows they were asked to exclude, and the orderings and the text operators matched the serialization. The draft preview (`?preview=draft`) gave the same counts over the drafted rows. TO: `400 INVALID_FILTER` before anything runs, in the words `POST /api/v1/data/:object/query` answers, naming the field and the operator, on every dialect. The ObjectQL strategy already answered this. On a datasource whose SQL dialect the host cannot name (memory, MongoDB), the native strategy now declines such a query, so the engine answers it through its own driver. +- FROM: the native SQL strategy compared the stored JSON text (`["a","b"]`) against the comparand and answered `200`: `$in` / `$eq` counted no row, `$nin` / `$ne` counted the rows they were asked to exclude, and the orderings and the text operators matched the serialization. The draft preview (`?preview=draft`) gave the same counts over the drafted rows. TO: `400 INVALID_FILTER` before anything runs, in the words `POST /api/v1/data/:object/query` answers, naming the field and the operator, on every dialect. The ObjectQL strategy already answered this. On a datasource whose SQL dialect the host cannot name (memory, MongoDB), the native strategy now declines a query whose `where`, dataset `filter`, measure `filter` or read scope carries such a comparison, so the engine answers it through its own driver; a `timeDimensions[].dateRange` window on such a field is not part of that decline, and is refused `400 INVALID_FILTER` on every datasource the native strategy compiles for. **Not moved.** `$contains` / `$notContains` (membership), `$null`, `$exists` and `$empty` on such a field, `$eq: null` / `$ne: null` (a null predicate), an empty `$in` / `$nin`, and every operator on a scalar field answer as before. diff --git a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts index b858855383e..9f1452bc717 100644 --- a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts +++ b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts @@ -362,12 +362,13 @@ describe('[#36264] svc.query and svc.generateSql refuse it too, on a named diale name: OBJECT, sql: OBJECT, measures: { cnt: { label: 'Count', type: 'count', sql: '*' } }, - dimensions: { seen: { label: 'Seen', type: 'time', sql: 'seen' } }, + dimensions: { seen: { label: 'Seen', type: 'time', sql: 'seen' }, day: { label: 'Day', type: 'time', sql: 'day' } }, public: true, } as unknown as Cube; const SHAPES: Record = { tags: { type: 'select', multiple: true }, seen: { type: 'tags' }, + day: { type: 'datetime' }, }; const svc = new AnalyticsService({ cubes: [CUBE], @@ -390,9 +391,13 @@ describe('[#36264] svc.query and svc.generateSql refuse it too, on a named diale }); } - it('query: a timeDimensions dateRange on such a member → 400 INVALID_FILTER (its window is a $gte / $lte filter)', async () => { - const err = await refusalOf(ask('query', { timeDimensions: [{ dimension: 'seen', dateRange: ['2026-01-01', '2026-02-01'] }] })); - expect(err.code, err.message).toBe('INVALID_FILTER'); - expect(err.status).toBe(400); - }); + for (const door of ['query', 'generateSql'] as const) { + it(`${door}: a timeDimensions dateRange on such a member → 400 INVALID_FILTER; CONTROL: on a scalar time column it answers`, async () => { + const window = (dimension: string) => ({ timeDimensions: [{ dimension, dateRange: ['2026-01-01', '2026-02-01'] }] }); + const err = await refusalOf(ask(door, window('seen'))); + expect(err.code, err.message).toBe('INVALID_FILTER'); + expect(err.status).toBe(400); + await expect(ask(door, window('day'))).resolves.toBeDefined(); + }); + } }); From 225d687392a981b98a8944f72eaa9f175c3c197a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 14:15:25 +0000 Subject: [PATCH 4/5] test(service-analytics): type the dateRange window helper as Partial Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude --- .../src/__tests__/dataset-json-column-refusal-36168.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts index 9f1452bc717..f43c0dcd128 100644 --- a/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts +++ b/packages/services/service-analytics/src/__tests__/dataset-json-column-refusal-36168.test.ts @@ -393,7 +393,7 @@ describe('[#36264] svc.query and svc.generateSql refuse it too, on a named diale for (const door of ['query', 'generateSql'] as const) { it(`${door}: a timeDimensions dateRange on such a member → 400 INVALID_FILTER; CONTROL: on a scalar time column it answers`, async () => { - const window = (dimension: string) => ({ timeDimensions: [{ dimension, dateRange: ['2026-01-01', '2026-02-01'] }] }); + const window = (dimension: string): Partial => ({ timeDimensions: [{ dimension, dateRange: ['2026-01-01', '2026-02-01'] }] }); const err = await refusalOf(ask(door, window('seen'))); expect(err.code, err.message).toBe('INVALID_FILTER'); expect(err.status).toBe(400); From 7859d6d494a414c3945b43d982f0f31ef53f3b74 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 19:32:50 +0000 Subject: [PATCH 5/5] fix(service-analytics): changeset drops read scope from the unknown-dialect decline list Claude-Session: https://claude.ai/code/session_011y7As6FyXmJyGyHNKXUkV7 Co-authored-by: Claude --- .changeset/36168-dataset-json-column-refusal.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/36168-dataset-json-column-refusal.md b/.changeset/36168-dataset-json-column-refusal.md index fa0768ef01e..2b5bc021ca4 100644 --- a/.changeset/36168-dataset-json-column-refusal.md +++ b/.changeset/36168-dataset-json-column-refusal.md @@ -11,7 +11,7 @@ Metadata-protocol: none **BREAKING** for a client of `POST /api/v1/analytics/dataset/query` (and every other caller of the dataset query on the native SQL strategy or the draft preview) whose `runtimeFilter`, dataset `filter` or measure `filter`, and for a client of `POST /api/v1/analytics/query` or of `POST /api/v1/analytics/sql` answered by the native SQL strategy whose `where`, applies an operator of `JSON_COLUMN_INCOMPATIBLE_OPERATORS` (`@objectstack/core`) — `$eq` or implicit equality, `$ne`, `$in`, `$nin`, `$gt` / `$gte` / `$lt` / `$lte`, `$between`, `$startsWith`, `$endsWith`, `$icontains` — to a multi-value or JSON field: an inherently multi-value type (`tags`, `multiselect`, `checkboxes`), a `select`, `radio`, `lookup`, `user`, `file` or `image` field declared `multiple: true`, or a structured-JSON type. The same holds on all three doors, when the native SQL strategy answers, for a `timeDimensions[].dateRange` window on such a field (the dataset door's `selection.timeDimensions[]` included), which compiles to a `$gte` / `$lte` pair: -- FROM: the native SQL strategy compared the stored JSON text (`["a","b"]`) against the comparand and answered `200`: `$in` / `$eq` counted no row, `$nin` / `$ne` counted the rows they were asked to exclude, and the orderings and the text operators matched the serialization. The draft preview (`?preview=draft`) gave the same counts over the drafted rows. TO: `400 INVALID_FILTER` before anything runs, in the words `POST /api/v1/data/:object/query` answers, naming the field and the operator, on every dialect. The ObjectQL strategy already answered this. On a datasource whose SQL dialect the host cannot name (memory, MongoDB), the native strategy now declines a query whose `where`, dataset `filter`, measure `filter` or read scope carries such a comparison, so the engine answers it through its own driver; a `timeDimensions[].dateRange` window on such a field is not part of that decline, and is refused `400 INVALID_FILTER` on every datasource the native strategy compiles for. +- FROM: the native SQL strategy compared the stored JSON text (`["a","b"]`) against the comparand and answered `200`: `$in` / `$eq` counted no row, `$nin` / `$ne` counted the rows they were asked to exclude, and the orderings and the text operators matched the serialization. The draft preview (`?preview=draft`) gave the same counts over the drafted rows. TO: `400 INVALID_FILTER` before anything runs, in the words `POST /api/v1/data/:object/query` answers, naming the field and the operator, on every dialect. The ObjectQL strategy already answered this. On a datasource whose SQL dialect the host cannot name (memory, MongoDB), the native strategy now declines a query whose `where`, dataset `filter` or measure `filter` carries such a comparison, so the engine answers it through its own driver; a `timeDimensions[].dateRange` window on such a field is not part of that decline, and is refused `400 INVALID_FILTER` on every datasource the native strategy compiles for. **Not moved.** `$contains` / `$notContains` (membership), `$null`, `$exists` and `$empty` on such a field, `$eq: null` / `$ne: null` (a null predicate), an empty `$in` / `$nin`, and every operator on a scalar field answer as before.