Skip to content

Commit dedf2e8

Browse files
committed
test(objectql): pin the refusal where two engine tests pinned the all-unknown search-override fallback
`engine-search-empty-set` and `internal-field-positions` asserted that an override naming only fields outside the allowed set fell back to that set. They now assert the refusal, and the second keeps a partly-known override's intersection as its control. The query-syntax page says what the engine now does with such an override. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyi29iG8J3UUXr68AZ
1 parent 7d84d05 commit dedf2e8

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎content/docs/protocol/objectql/query-syntax.mdx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,10 @@ plus short-text/enum fields), so naming a field outside that set can never widen
11901190
search — and over the REST/protocol ingress it is `400 INVALID_FIELD` outright (#4254),
11911191
because the engine-side intersection alone used to drop the unknown name and fall back to
11921192
scanning the full searchable set. Internal callers reaching `engine.find()` directly keep
1193-
the tolerant intersection, but not a search with nothing to scan: when no
1193+
the tolerant intersection for an override naming at least one searchable field (the other
1194+
names are dropped), but an override naming none of them is refused there too,
1195+
`400 INVALID_FIELD`, rather than widened to the full set. Nor is a search with nothing to
1196+
scan answered: when no
11941197
`searchableFields` entry names a stored field and the auto-default finds none
11951198
(`internal: true` fields never count), the engine itself refuses a non-blank `search`
11961199
with `400 INVALID_FIELD` (`param: 'search'`) on `find`, `findOne`, `count` and

‎packages/objectql/src/engine-search-empty-set.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ describe('[#24284] a search over an empty resolved search set is refused', () =>
176176
}
177177
});
178178

179-
it('control: an object with a stored text field still filters, and an override intersected to nothing falls back to its set', async () => {
179+
it('control: an object with a stored text field still filters, and an override intersected to nothing is refused', async () => {
180180
expect((await engine.find('lib_book', { search: 'Dune' })).map((r) => r.id)).toEqual(['b1']);
181181
expect(await engine.find('lib_book', { search: 'zzzz-nothing' })).toEqual([]);
182182
expect(await engine.count('lib_book', { search: 'zzzz-nothing' })).toBe(0);
183-
// A direct engine caller naming only fields outside the allowed set: the
184-
// tolerant intersection falls back to the allowed set — a FILTERED
185-
// answer, never every row.
186-
expect((await engine.find('lib_book', { search: 'emma', searchFields: ['nope'] })).map((r) => r.id)).toEqual(['b2']);
183+
// [#28120] A direct engine caller naming only fields outside the allowed
184+
// set is refused, never answered over the whole allowed set.
185+
await expect(engine.find('lib_book', { search: 'emma', searchFields: ['nope'] }))
186+
.rejects.toMatchObject({ status: 400, code: 'INVALID_FIELD', param: 'searchFields', field: 'nope' });
187187
});
188188
});
189189

‎packages/objectql/src/internal-field-positions.test.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ describe('[#22646] a $search never scans an `internal: true` column', () => {
141141
expect(blob).not.toContain('token');
142142
});
143143

144-
it('an explicit searchFields naming the flagged column is intersected away at the engine (withheld)', async () => {
144+
it('an explicit searchFields naming only the flagged column is refused at the engine, never scanned', async () => {
145145
await ctx.engine.insert('itest_vault', { name: 'alpha', prefix: 'osk_', rank: 1, token: 'h1' }, SYSTEM as any);
146-
await ctx.engine.find('itest_vault', { search: 'h1', searchFields: ['token'] }, SYSTEM);
146+
const reads = ctx.seenWhere.length;
147+
// [#28120] The override names nothing scannable (the flagged column is
148+
// withheld), so it is refused rather than widened to the default set.
149+
await expect(ctx.engine.find('itest_vault', { search: 'h1', searchFields: ['token'] }, SYSTEM))
150+
.rejects.toMatchObject({ status: 400, code: 'INVALID_FIELD', param: 'searchFields' });
151+
expect(ctx.seenWhere.length).toBe(reads);
152+
// Named beside a scannable field, it is still intersected away: never a clause on `token`.
153+
await ctx.engine.find('itest_vault', { search: 'h1', searchFields: ['name', 'token'] }, SYSTEM);
147154
const blob = JSON.stringify(lastSearchWhere() ?? null);
148-
// The override narrowed to nothing scannable, so the engine falls back
149-
// to the (internal-free) default set — never a clause on `token`.
155+
expect(blob).toContain('name');
150156
expect(blob).not.toContain('token');
151157
});
152158

0 commit comments

Comments
 (0)