Skip to content

Commit 6a72327

Browse files
Copilothotlong
andcommitted
test: add stronger legacy-key-ignored tests per code review feedback
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/61332fa6-4cc7-491f-b72c-2c73c6357e02
1 parent d263b28 commit 6a72327

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/plugins/driver-sql/src/sql-driver-queryast.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,29 @@ describe('SqlDriver (QueryAST Format)', () => {
186186
expect(results.length).toBe(5);
187187
});
188188

189+
it('should use "where" and ignore "filters" when both are present', async () => {
190+
const results = await driver.find('products', {
191+
where: [['category', '=', 'Electronics']],
192+
filters: [['category', '=', 'Furniture']],
193+
} as any);
194+
195+
// Only "where" is applied — returns Electronics, not Furniture
196+
expect(results.every((r: any) => r.category === 'Electronics')).toBe(true);
197+
expect(results.length).toBe(3);
198+
});
199+
189200
it('should ignore legacy "sort" key — only "orderBy" is recognized', async () => {
190201
const results = await driver.find('products', {
191202
fields: ['name'],
192-
limit: 2,
203+
limit: 5,
204+
orderBy: [{ field: 'price', order: 'desc' as const }],
193205
sort: [{ field: 'price', order: 'asc' as const }],
194206
} as any);
195207

196-
// "sort" is not recognized — no ORDER BY applied, so order is insertion order
197-
expect(results.length).toBe(2);
198-
// Without ORDER BY, results come in insertion order (Laptop, Mouse)
208+
// "sort" is ignored; "orderBy" (desc) is applied — most expensive first
209+
expect(results.length).toBe(5);
199210
expect(results[0].name).toBe('Laptop');
211+
expect(results[4].name).toBe('Mouse');
200212
});
201213

202214
it('should ignore legacy "skip" key — only "offset" is recognized', async () => {

0 commit comments

Comments
 (0)