Skip to content

Commit aea4852

Browse files
committed
docs(spec): carry the collation latitude into the aggregate() contract and name Oracle as unmeasured
The aggregate() TSDoc said a driver declaring aggregationFilter answers each measure filter with the in-memory path's answers; it now defers to the latitude the bit states. The bit's TSDoc and the changeset name Oracle beside MySQL and SQL Server as not measured. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nSNBMzF8jj9quUkjf
1 parent 8e48947 commit aea4852

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎.changeset/33698-measure-filter-pushdown.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ Metadata-protocol: semantic
2323

2424
**A measure filter the `where` compiler refuses now refuses on driver-sql.** Because driver-sql compiles a measure filter with the same where compiler, a filter that compiler refuses answers the same `400 INVALID_FILTER` its `where` twin answers. The recorded case is a `{ $field }` comparison between columns of different classes on an object with no audit fields (`created_at` against an image field): before, the engine evaluated it in memory and answered `200`; on driver-sql it now answers `400 INVALID_FILTER`, as `where` always did. A driver without the bit still evaluates it in memory and answers `200`.
2525

26-
**Declared latitude: text compares by the database collation.** On driver-sql a measure filter now answers what the `where` of the same datasource answers, so text comparison in it follows the database collation, where the in-memory path compares text exactly. Ordering a non-temporal text column (`$gt` / `$lt` / `$between` on text) follows the collation everywhere; on a case- or accent-insensitive collation, equality and membership do too, so `stage $eq 'won'` also counts `Won` rows, as `where` already does. Measured: SQLite and PostgreSQL 16 agree with the in-memory path on every operator with a `C.UTF-8` collation; PostgreSQL 16 with an ICU `en-US` collation differs only in text ordering. MySQL and SQL Server were not measured; their default collations are case-insensitive.
26+
**Declared latitude: text compares by the database collation.** On driver-sql a measure filter now answers what the `where` of the same datasource answers, so text comparison in it follows the database collation, where the in-memory path compares text exactly. Ordering a non-temporal text column (`$gt` / `$lt` / `$between` on text) follows the collation everywhere; on a case- or accent-insensitive collation, equality and membership do too, so `stage $eq 'won'` also counts `Won` rows, as `where` already does. Measured: SQLite and PostgreSQL 16 agree with the in-memory path on every operator with a `C.UTF-8` collation; PostgreSQL 16 with an ICU `en-US` collation differs only in text ordering. MySQL, SQL Server and Oracle were not measured; the MySQL and SQL Server default collations are case-insensitive.

‎packages/spec/src/contracts/data-driver.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ export interface IDataDriver {
232232
* road. `aggregations[].filter` (#10576) reaches this method only on a driver
233233
* that declares `supports.aggregationFilter` (#33698, `DriverCapabilities`),
234234
* which then evaluates each measure's filter with the in-memory path's
235-
* answers; on every other driver it forces the in-memory path.
235+
* answers except where `DriverCapabilities.aggregationFilter` states a
236+
* latitude (text compares by the backend collation, as in `where`); on every
237+
* other driver it forces the in-memory path.
236238
*
237239
* What a driver returns: one row per group, keyed by the `groupBy` field
238240
* names and by each aggregation's `alias`, with the per-function value

‎packages/spec/src/data/driver.zod.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,11 @@ export const DriverCapabilitiesSchema = lazySchema(() => z.object({
310310
* Measured (in-memory path against driver-sql's where compiler, 119
311311
* filters): SQLite, and PostgreSQL 16 with a `C.UTF-8` database collation,
312312
* answer alike on every operator; PostgreSQL 16 with an ICU `en-US` database
313-
* collation differs only in text ordering. NOT measured: MySQL and SQL
314-
* Server, whose default collations are case-insensitive, so equality and
315-
* membership on text are expected to fold case there. Numbers, booleans,
316-
* dates, datetimes and times answer alike wherever measured.
313+
* collation differs only in text ordering. NOT measured: MySQL, SQL Server
314+
* and Oracle. The MySQL and SQL Server default collations are
315+
* case-insensitive, so equality and membership on text are expected to
316+
* fold case there. Numbers, booleans, dates, datetimes and times answer
317+
* alike wherever measured.
317318
*
318319
* What the engine does with it: `engine.aggregate` sends an aggregate whose
319320
* measures carry a filter to `driver.aggregate` only when this bit is `true`

0 commit comments

Comments
 (0)