Skip to content

Commit e652547

Browse files
CopilotCopilot
andcommitted
fix: update test assertions to match QueryAST-standard parameter names
- engine.test.ts: change populate:[...] to expand:{relName:{object:relName}} - protocol-data.test.ts: update expects for where/fields/orderBy/offset/expand - All 151 tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 17dca13 commit e652547

5 files changed

Lines changed: 170 additions & 80 deletions

File tree

content/docs/references/data/data-engine.mdx

Lines changed: 107 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ The Data Engine acts as the "Driver" layer in the Hexagonal Architecture.
2424
## TypeScript Usage
2525

2626
```typescript
27-
import { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest } from '@objectstack/spec/data';
28-
import type { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest } from '@objectstack/spec/data';
27+
import { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest, EngineAggregateOptions, EngineCountOptions, EngineDeleteOptions, EngineQueryOptions, EngineUpdateOptions } from '@objectstack/spec/data';
28+
import type { BaseEngineOptions, DataEngineAggregateOptions, DataEngineAggregateRequest, DataEngineBatchRequest, DataEngineCountOptions, DataEngineCountRequest, DataEngineDeleteOptions, DataEngineDeleteRequest, DataEngineExecuteRequest, DataEngineFilter, DataEngineFindOneRequest, DataEngineFindRequest, DataEngineInsertOptions, DataEngineInsertRequest, DataEngineQueryOptions, DataEngineRequest, DataEngineSort, DataEngineUpdateOptions, DataEngineUpdateRequest, DataEngineVectorFindRequest, EngineAggregateOptions, EngineCountOptions, EngineDeleteOptions, EngineQueryOptions, EngineUpdateOptions } from '@objectstack/spec/data';
2929

3030
// Validate data
3131
const result = BaseEngineOptions.parse(data);
@@ -68,7 +68,7 @@ Options for DataEngine.aggregate operations
6868
| :--- | :--- | :--- | :--- |
6969
| **method** | `string` || |
7070
| **object** | `string` || |
71-
| **query** | `Object` || Options for DataEngine.aggregate operations |
71+
| **query** | `Object` || QueryAST-aligned options for DataEngine.aggregate operations |
7272

7373

7474
---
@@ -108,7 +108,7 @@ Options for DataEngine.count operations
108108
| :--- | :--- | :--- | :--- |
109109
| **method** | `string` || |
110110
| **object** | `string` || |
111-
| **query** | `Object` | optional | Options for DataEngine.count operations |
111+
| **query** | `Object` | optional | QueryAST-aligned options for DataEngine.count operations |
112112

113113

114114
---
@@ -136,8 +136,8 @@ Options for DataEngine.delete operations
136136
| :--- | :--- | :--- | :--- |
137137
| **method** | `string` || |
138138
| **object** | `string` || |
139-
| **id** | `string \| number` | optional | ID for single delete, or use filter in options |
140-
| **options** | `Object` | optional | Options for DataEngine.delete operations |
139+
| **id** | `string \| number` | optional | ID for single delete, or use where in options |
140+
| **options** | `Object` | optional | QueryAST-aligned options for DataEngine.delete operations |
141141

142142

143143
---
@@ -186,7 +186,7 @@ Reference: [__schema0](./__schema0)
186186
| :--- | :--- | :--- | :--- |
187187
| **method** | `string` || |
188188
| **object** | `string` || |
189-
| **query** | `Object` | optional | Query options for IDataEngine.find() operations |
189+
| **query** | `Object` | optional | QueryAST-aligned query options for IDataEngine.find() operations |
190190

191191

192192
---
@@ -199,7 +199,7 @@ Reference: [__schema0](./__schema0)
199199
| :--- | :--- | :--- | :--- |
200200
| **method** | `string` || |
201201
| **object** | `string` || |
202-
| **query** | `Object` | optional | Query options for IDataEngine.find() operations |
202+
| **query** | `Object` | optional | QueryAST-aligned query options for IDataEngine.find() operations |
203203

204204

205205
---
@@ -268,7 +268,7 @@ This schema accepts one of the following structures:
268268
| :--- | :--- | :--- | :--- |
269269
| **method** | `string` || |
270270
| **object** | `string` || |
271-
| **query** | `Object` | optional | Query options for IDataEngine.find() operations |
271+
| **query** | `Object` | optional | QueryAST-aligned query options for IDataEngine.find() operations |
272272

273273
---
274274

@@ -280,7 +280,7 @@ This schema accepts one of the following structures:
280280
| :--- | :--- | :--- | :--- |
281281
| **method** | `string` || |
282282
| **object** | `string` || |
283-
| **query** | `Object` | optional | Query options for IDataEngine.find() operations |
283+
| **query** | `Object` | optional | QueryAST-aligned query options for IDataEngine.find() operations |
284284

285285
---
286286

@@ -306,8 +306,8 @@ This schema accepts one of the following structures:
306306
| **method** | `string` || |
307307
| **object** | `string` || |
308308
| **data** | `Record<string, any>` || |
309-
| **id** | `string \| number` | optional | ID for single update, or use filter in options |
310-
| **options** | `Object` | optional | Options for DataEngine.update operations |
309+
| **id** | `string \| number` | optional | ID for single update, or use where in options |
310+
| **options** | `Object` | optional | QueryAST-aligned options for DataEngine.update operations |
311311

312312
---
313313

@@ -319,8 +319,8 @@ This schema accepts one of the following structures:
319319
| :--- | :--- | :--- | :--- |
320320
| **method** | `string` || |
321321
| **object** | `string` || |
322-
| **id** | `string \| number` | optional | ID for single delete, or use filter in options |
323-
| **options** | `Object` | optional | Options for DataEngine.delete operations |
322+
| **id** | `string \| number` | optional | ID for single delete, or use where in options |
323+
| **options** | `Object` | optional | QueryAST-aligned options for DataEngine.delete operations |
324324

325325
---
326326

@@ -332,7 +332,7 @@ This schema accepts one of the following structures:
332332
| :--- | :--- | :--- | :--- |
333333
| **method** | `string` || |
334334
| **object** | `string` || |
335-
| **query** | `Object` | optional | Options for DataEngine.count operations |
335+
| **query** | `Object` | optional | QueryAST-aligned options for DataEngine.count operations |
336336

337337
---
338338

@@ -344,7 +344,7 @@ This schema accepts one of the following structures:
344344
| :--- | :--- | :--- | :--- |
345345
| **method** | `string` || |
346346
| **object** | `string` || |
347-
| **query** | `Object` || Options for DataEngine.aggregate operations |
347+
| **query** | `Object` || QueryAST-aligned options for DataEngine.aggregate operations |
348348

349349
---
350350

@@ -381,8 +381,8 @@ This schema accepts one of the following structures:
381381
| **method** | `string` || |
382382
| **object** | `string` || |
383383
| **vector** | `number[]` || |
384-
| **filter** | `Record<string, any> \| [__schema0](./__schema0)` | optional | Data Engine query filter conditions |
385-
| **select** | `string[]` | optional | |
384+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
385+
| **fields** | `string[]` | optional | |
386386
| **limit** | `integer` | optional | |
387387
| **threshold** | `number` | optional | |
388388

@@ -446,8 +446,8 @@ Options for DataEngine.update operations
446446
| **method** | `string` || |
447447
| **object** | `string` || |
448448
| **data** | `Record<string, any>` || |
449-
| **id** | `string \| number` | optional | ID for single update, or use filter in options |
450-
| **options** | `Object` | optional | Options for DataEngine.update operations |
449+
| **id** | `string \| number` | optional | ID for single update, or use where in options |
450+
| **options** | `Object` | optional | QueryAST-aligned options for DataEngine.update operations |
451451

452452

453453
---
@@ -461,11 +461,96 @@ Options for DataEngine.update operations
461461
| **method** | `string` || |
462462
| **object** | `string` || |
463463
| **vector** | `number[]` || |
464-
| **filter** | `Record<string, any> \| [__schema0](./__schema0)` | optional | Data Engine query filter conditions |
465-
| **select** | `string[]` | optional | |
464+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
465+
| **fields** | `string[]` | optional | |
466466
| **limit** | `integer` | optional | |
467467
| **threshold** | `number` | optional | |
468468

469469

470470
---
471471

472+
## EngineAggregateOptions
473+
474+
QueryAST-aligned options for DataEngine.aggregate operations
475+
476+
### Properties
477+
478+
| Property | Type | Required | Description |
479+
| :--- | :--- | :--- | :--- |
480+
| **context** | `Object` | optional | |
481+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
482+
| **groupBy** | `string[]` | optional | |
483+
| **aggregations** | `Object[]` | optional | |
484+
485+
486+
---
487+
488+
## EngineCountOptions
489+
490+
QueryAST-aligned options for DataEngine.count operations
491+
492+
### Properties
493+
494+
| Property | Type | Required | Description |
495+
| :--- | :--- | :--- | :--- |
496+
| **context** | `Object` | optional | |
497+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
498+
499+
500+
---
501+
502+
## EngineDeleteOptions
503+
504+
QueryAST-aligned options for DataEngine.delete operations
505+
506+
### Properties
507+
508+
| Property | Type | Required | Description |
509+
| :--- | :--- | :--- | :--- |
510+
| **context** | `Object` | optional | |
511+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
512+
| **multi** | `boolean` | optional | |
513+
514+
515+
---
516+
517+
## EngineQueryOptions
518+
519+
QueryAST-aligned query options for IDataEngine.find() operations
520+
521+
### Properties
522+
523+
| Property | Type | Required | Description |
524+
| :--- | :--- | :--- | :--- |
525+
| **context** | `Object` | optional | |
526+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
527+
| **fields** | `[__schema1](./__schema1)[]` | optional | |
528+
| **orderBy** | `Object[]` | optional | |
529+
| **limit** | `number` | optional | |
530+
| **offset** | `number` | optional | |
531+
| **top** | `number` | optional | |
532+
| **cursor** | `Record<string, any>` | optional | |
533+
| **search** | `Object` | optional | |
534+
| **expand** | `Record<string, [__schema2](./__schema2)>` | optional | |
535+
| **distinct** | `boolean` | optional | |
536+
537+
538+
---
539+
540+
## EngineUpdateOptions
541+
542+
QueryAST-aligned options for DataEngine.update operations
543+
544+
### Properties
545+
546+
| Property | Type | Required | Description |
547+
| :--- | :--- | :--- | :--- |
548+
| **context** | `Object` | optional | |
549+
| **where** | `Record<string, any> \| [__schema0](./__schema0)` | optional | |
550+
| **upsert** | `boolean` | optional | |
551+
| **multi** | `boolean` | optional | |
552+
| **returning** | `boolean` | optional | |
553+
554+
555+
---
556+

content/docs/references/data/driver.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const result = DriverCapabilities.parse(data);
5757
| **arrayFields** | `boolean` || Supports array field types |
5858
| **vectorSearch** | `boolean` || Supports vector embeddings and similarity search |
5959
| **schemaSync** | `boolean` || Supports automatic schema synchronization |
60+
| **batchSchemaSync** | `boolean` || Supports batched schema sync to reduce schema DDL round-trips |
6061
| **migrations** | `boolean` || Supports database migrations |
6162
| **indexes** | `boolean` || Supports index creation and management |
6263
| **connectionPooling** | `boolean` || Supports connection pooling |

packages/objectql/src/engine.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('ObjectQL Engine', () => {
248248
{ id: 'u2', name: 'Bob' },
249249
]);
250250

251-
const result = await engine.find('task', { populate: ['assignee'] });
251+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
252252

253253
expect(result).toHaveLength(2);
254254
expect(result[0].assignee).toEqual({ id: 'u1', name: 'Alice' });
@@ -288,7 +288,7 @@ describe('ObjectQL Engine', () => {
288288
{ id: 'o1', total: 100 },
289289
]);
290290

291-
const result = await engine.find('order_item', { populate: ['order'] });
291+
const result = await engine.find('order_item', { expand: { order: { object: 'order' } } });
292292
expect(result[0].order).toEqual({ id: 'o1', total: 100 });
293293
});
294294

@@ -304,7 +304,7 @@ describe('ObjectQL Engine', () => {
304304
{ id: 't1', title: 'Task 1' },
305305
]);
306306

307-
const result = await engine.find('task', { populate: ['title'] });
307+
const result = await engine.find('task', { expand: { title: { object: 'title' } } });
308308
expect(result[0].title).toBe('Task 1'); // Unchanged
309309
expect(mockDriver.find).toHaveBeenCalledTimes(1); // No expand query
310310
});
@@ -316,7 +316,7 @@ describe('ObjectQL Engine', () => {
316316
{ id: 't1', assignee: 'u1' },
317317
]);
318318

319-
const result = await engine.find('task', { populate: ['assignee'] });
319+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
320320
expect(result[0].assignee).toBe('u1'); // Unchanged — raw ID
321321
expect(mockDriver.find).toHaveBeenCalledTimes(1);
322322
});
@@ -345,7 +345,7 @@ describe('ObjectQL Engine', () => {
345345
{ id: 'u1', name: 'Alice' },
346346
]);
347347

348-
const result = await engine.find('task', { populate: ['assignee'] });
348+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
349349
expect(result[0].assignee).toBeNull();
350350
expect(result[1].assignee).toEqual({ id: 'u1', name: 'Alice' });
351351
});
@@ -376,7 +376,7 @@ describe('ObjectQL Engine', () => {
376376
{ id: 'u2', name: 'Bob' },
377377
]);
378378

379-
const result = await engine.find('task', { populate: ['assignee'] });
379+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
380380

381381
// Verify only 2 unique IDs queried
382382
expect(mockDriver.find).toHaveBeenLastCalledWith(
@@ -410,7 +410,7 @@ describe('ObjectQL Engine', () => {
410410
])
411411
.mockResolvedValueOnce([]); // No records found
412412

413-
const result = await engine.find('task', { populate: ['assignee'] });
413+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
414414
expect(result[0].assignee).toBe('u_deleted'); // Fallback to raw ID
415415
});
416416

@@ -441,7 +441,7 @@ describe('ObjectQL Engine', () => {
441441
.mockResolvedValueOnce([{ id: 'u1', name: 'Alice' }])
442442
.mockResolvedValueOnce([{ id: 'p1', name: 'Project X' }]);
443443

444-
const result = await engine.find('task', { populate: ['assignee', 'project'] });
444+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' }, project: { object: 'project' } } });
445445

446446
expect(result[0].assignee).toEqual({ id: 'u1', name: 'Alice' });
447447
expect(result[0].project).toEqual({ id: 'p1', name: 'Project X' });
@@ -470,7 +470,7 @@ describe('ObjectQL Engine', () => {
470470
{ id: 'u1', name: 'Alice' },
471471
]);
472472

473-
const result = await engine.findOne('task', { populate: ['assignee'] });
473+
const result = await engine.findOne('task', { expand: { assignee: { object: 'assignee' } } });
474474

475475
expect(result.assignee).toEqual({ id: 'u1', name: 'Alice' });
476476
});
@@ -495,7 +495,7 @@ describe('ObjectQL Engine', () => {
495495
{ id: 't1', assignee: { id: 'u1', name: 'Alice' } },
496496
]);
497497

498-
const result = await engine.find('task', { populate: ['assignee'] });
498+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
499499

500500
// No expand query should have been made — the value was already an object
501501
expect(mockDriver.find).toHaveBeenCalledTimes(1);
@@ -523,7 +523,7 @@ describe('ObjectQL Engine', () => {
523523
])
524524
.mockRejectedValueOnce(new Error('Driver connection failed'));
525525

526-
const result = await engine.find('task', { populate: ['assignee'] });
526+
const result = await engine.find('task', { expand: { assignee: { object: 'assignee' } } });
527527
expect(result[0].assignee).toBe('u1'); // Kept raw ID
528528
});
529529

@@ -551,7 +551,7 @@ describe('ObjectQL Engine', () => {
551551
{ id: 'u2', name: 'Bob' },
552552
]);
553553

554-
const result = await engine.find('task', { populate: ['watchers'] });
554+
const result = await engine.find('task', { expand: { watchers: { object: 'watchers' } } });
555555
expect(result[0].watchers).toEqual([
556556
{ id: 'u1', name: 'Alice' },
557557
{ id: 'u2', name: 'Bob' },
@@ -574,7 +574,7 @@ describe('ObjectQL Engine', () => {
574574
.mockResolvedValueOnce([{ id: 'p1', org: 'o1' }]); // expand project (depth 0)
575575
// org should NOT be expanded further — flat populate doesn't create nested expand
576576

577-
const result = await engine.find('task', { populate: ['project'] });
577+
const result = await engine.find('task', { expand: { project: { object: 'project' } } });
578578

579579
// Project expanded, but org inside project remains as raw ID
580580
expect(result[0].project).toEqual({ id: 'p1', org: 'o1' });

0 commit comments

Comments
 (0)