Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/aggregate-unresolvable-column-refusal.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@objectstack/driver-sql": patch
---

`aggregate()` now answers an unresolvable column with the same refusal class as `find()` and `count()` instead of the generic `DATABASE_ERROR`/500 terminal — the #8790 refusal reaching the third read door (#11541). The dialect-named column is attributed to the clause the caller's own query names it in: a `groupBy` field or an aggregation `field` refuses with `INVALID_FIELD`/400 naming the column and the clause (the same code the protocol ingress gives this condition, #4254); a column named by neither clause is the WHERE, which answers #8790's `INVALID_FILTER`/400 refusal verbatim; a dialect wording that yields no column name keeps the #11455 terminal envelope unchanged, because no attribution is supportable there (#8931). Drivers extending `SqlDriver` (`driver-turso`'s embedded face, `driver-sqlite-wasm`) inherit the same answers.
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,12 +74,17 @@
*
* ## What is deliberately NOT here
*
* ⛔ No `isUnresolvableColumnError` arm, unlike `count()`. That refusal's words
* are *"Filter on 'x' names a column that object 'o' has no column for"*, and
* this door names columns in THREE clauses — the WHERE, the `groupBy` fields
* and the aggregation `field`. A blanket arm would tell the author of
* `avg('nosuchcol')` that their FILTER was wrong. Filed as its own card rather
* than guessed at here; see the note on `SqlDriver.aggregate`.
* ⛔ No BLANKET `isUnresolvableColumnError` arm, unlike `count()`. That
* refusal's words are *"Filter on 'x' names a column that object 'o' has no
* column for"*, and this door names columns in THREE clauses — the WHERE, the
* `groupBy` fields and the aggregation `field`. A blanket arm would tell the
* author of `avg('nosuchcol')` that their FILTER was wrong. This suite left
* the gap FILED rather than guessed at; #11541 has since closed it with a
* clause-attributing classifier (`SqlDriver.aggregateBackendFault`, pinned by
* `sql-driver-11541-aggregate-unresolvable-column-refusal.test.ts`). What this
* suite pins is unchanged by that: an error the classifier does NOT claim — a
* missing table, a `42883` function fault, a wording no dialect parser reads —
* still leaves as this terminal envelope, never as a clause verdict.
*/

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
Expand Down
Loading
Loading