Skip to content

Commit 26ebfb4

Browse files
committed
docs(objectql): changeset and the queries page for the empty-projection refusal
Claude-Session: https://claude.ai/code/session_01FEkQ5mbUpy4ebfWUHxAv87 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5a21e58 commit 26ebfb4

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/objectql': patch
3+
---
4+
5+
fix(objectql)!: the in-process engine refuses an empty projection, as every published declaration of a read's projection does (#27008)
6+
7+
Clause-②: no (narrowing) — `ObjectQL.find` / `findOne` refuse `fields: []`, and an `expand` entry's `fields: []` at any depth, which they read before as every column. Nothing is widened.
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped, and no export or type changes: EngineQueryOptionsSchema.fields already declares the refusal, and the engine now enforces it at its entry. There is nothing for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** accept-set narrowing at the in-process read entry (`@objectstack/objectql`).
13+
14+
- **Before.** The HTTP doors refuse `select: []` with `400 VALIDATION_ERROR`, and `EngineQueryOptionsSchema.fields` declares the same refusal, but `engine.find(object, { fields: [] })` and `findOne` never parsed their options with that schema. The empty list reached the driver, which serves it as no projection: every column came back, owner, organization and audit columns included, and the caller was not told. An `expand: { rel: { fields: [] } }` entry expanded every column of the related record the same way.
15+
- **Now.** Both entries refuse an empty projection before any driver read: the top-level `fields`, and every `expand` entry's `fields` at any depth. The error carries `status: 400` and `code: 'VALIDATION_ERROR'`, the answer the HTTP doors give, so `mapDataError` serves an in-process caller and a REST caller alike. Its words are the declaration's own (`Name at least one field`), read off `EngineQueryOptionsSchema.fields`. A system-context read is refused too: the rule is about the shape, not the caller.
16+
- **Unchanged.** An absent or `null` `fields` still reads every column. A non-empty projection projects as before, including the tolerance for an unknown plain column.
17+
- **Who sees it.** A plugin, hook, flow or other in-process caller that passed an empty projection, by mistake or by building one that came out empty. No in-repo caller does.
18+
19+
**The remedy.** Leave `fields` out to read every column, or name the columns to read.

‎content/docs/data-modeling/queries.mdx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ retired, read them with the operator-only
296296
them before `os migrate apply --allow-destructive` drops the column. No runtime door serves
297297
them.
298298

299+
`fields` names at least one column. An empty list (`fields: []`, `$select=`) is refused with
300+
`400 VALIDATION_ERROR` — on the data API, and by `engine.find()` / `findOne()` for an in-process
301+
caller (a plugin, a hook, a flow), the top-level `fields` and an `expand` entry's alike — rather
302+
than read as "every column". Leave `fields` out to read every column.
303+
299304
### Nested / Related Fields
300305

301306
{/* os:check */}

0 commit comments

Comments
 (0)