Skip to content

Commit a0825aa

Browse files
paddymulclaude
andcommitted
test(duckdb-node): cover row window after setSearch with no initialState
A `setSearch` followed directly by an `infinite_request` (no intervening `initialState`) must still window the filtered set and report the filtered length. Fails today: the window serves the stale full count. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1940aaf commit a0825aa

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/buckaroo-duckdb-node/test/backend.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ describe('DuckBackend search', () => {
212212
expect(src.lastCopyQuery).toContain('contains(');
213213
});
214214

215+
it('a setSearch with no intervening initialState still windows the filtered set', async () => {
216+
const src = searchableSource();
217+
const backend = new DuckBackend(src, 'SELECT * FROM t');
218+
await backend.initialState(); // seeds the unfiltered length (5)
219+
220+
// setSearch alone — the activeSql is derived on demand and the filtered
221+
// length recomputed here, so the window can't serve the stale full count.
222+
backend.setSearch('Al');
223+
const resp = await backend.handleInfiniteRequest({
224+
sourceName: 'main',
225+
start: 0,
226+
end: 10,
227+
origEnd: 10,
228+
});
229+
expect(resp.length).toBe(2);
230+
expect(src.lastCopyQuery).toContain('contains(');
231+
});
232+
215233
it('clearing the search restores the full view', async () => {
216234
const backend = new DuckBackend(searchableSource(), 'SELECT * FROM t');
217235
await backend.initialState();

0 commit comments

Comments
 (0)