Skip to content

Commit bfbeffe

Browse files
committed
test: the pins' store doubles hold the caller's limit (check:objectql-double-limit)
Claude-Session: https://claude.ai/code/session_017ErfyP2Rx7XWHJA27QjyUi Co-authored-by: Claude <noreply@anthropic.com>
1 parent e763836 commit bfbeffe

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

‎packages/objectql/src/write-result-declared-fields-conformance.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,21 @@ function makeSqlShapedStore() {
6060
}
6161
return true;
6262
};
63-
const run = (o: string, ast?: { where?: Row }): Row[] =>
64-
Array.from(tableFor(o).values()).filter((r) => matches(r, ast?.where)).map((r) => ({ ...r }));
63+
const run = (o: string, ast?: { where?: Row; limit?: number }): Row[] => {
64+
const rows = Array.from(tableFor(o).values()).filter((r) => matches(r, ast?.where));
65+
// The caller's bound, after the filter, by presence.
66+
const page = typeof ast?.limit === 'number' ? rows.slice(0, ast.limit) : rows;
67+
return page.map((r) => ({ ...r }));
68+
};
6569
let seq = 0;
6670
const driver = {
6771
name: 'store-sql-shaped', version: '0.0.0', supports: {},
6872
async connect(): Promise<void> {},
6973
async disconnect(): Promise<void> {},
7074
async checkHealth(): Promise<boolean> { return true; },
7175
async execute(): Promise<null> { return null; },
72-
async find(o: string, ast?: { where?: Row }): Promise<Row[]> { return run(o, ast); },
73-
async findOne(o: string, ast?: { where?: Row }): Promise<Row | null> { return run(o, ast)[0] ?? null; },
76+
async find(o: string, ast?: { where?: Row; limit?: number }): Promise<Row[]> { return run(o, ast); },
77+
async findOne(o: string, ast?: { where?: Row; limit?: number }): Promise<Row | null> { return run(o, ast)[0] ?? null; },
7478
async create(o: string, data: Row): Promise<Row> {
7579
seq += 1;
7680
// `returning('*')`: every physical column, an unwritten one null.

‎packages/plugins/plugin-audit/src/audit-ledger-declared-fields.test.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,20 @@ function makeSqlShapedStore() {
7474
return t;
7575
};
7676
const copy = <T,>(r: T): T => (r == null ? r : JSON.parse(JSON.stringify(r)));
77-
const run = (o: string, where?: Row): Row[] =>
78-
Array.from(tableFor(o).values())
79-
.filter((r) => Object.entries(where ?? {}).every(([k, v]) => k.startsWith('$') || (r[k] ?? null) === (v ?? null)))
80-
.map(copy);
77+
const run = (o: string, where?: Row, limit?: number): Row[] => {
78+
const rows = Array.from(tableFor(o).values())
79+
.filter((r) => Object.entries(where ?? {}).every(([k, v]) => k.startsWith('$') || (r[k] ?? null) === (v ?? null)));
80+
// The caller's bound, after the filter, by presence.
81+
const page = typeof limit === 'number' ? rows.slice(0, limit) : rows;
82+
return page.map(copy);
83+
};
8184
let seq = 0;
8285
const driver: any = {
8386
name: 'store-sql-shaped', version: '0.0.0', supports: {},
8487
async connect() {}, async disconnect() {}, async checkHealth() { return true; },
8588
async execute() { return null; },
86-
async find(o: string, ast?: { where?: Row }) { return run(o, ast?.where); },
87-
async findOne(o: string, ast?: { where?: Row }) { return run(o, ast?.where)[0] ?? null; },
89+
async find(o: string, ast?: { where?: Row; limit?: number }) { return run(o, ast?.where, ast?.limit); },
90+
async findOne(o: string, ast?: { where?: Row; limit?: number }) { return run(o, ast?.where, ast?.limit)[0] ?? null; },
8891
async create(o: string, data: Row) {
8992
seq += 1;
9093
const retired = o === CONTACT ? Object.fromEntries(RETIRED.map((c) => [c, null])) : {};

‎packages/plugins/plugin-webhooks/src/webhook-payload-declared-fields.test.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,22 @@ function makeSqlShapedStore() {
5858
if (!t) { t = new Map<string, Row>(); tables.set(o, t); }
5959
return t;
6060
};
61-
const run = (o: string, where?: Row): Row[] =>
62-
Array.from(tableFor(o).values())
63-
.filter((r) => Object.entries(where ?? {}).every(([k, v]) => k.startsWith('$') || (r[k] ?? null) === (v ?? null)))
64-
.map((r) => ({ ...r }));
61+
const run = (o: string, where?: Row, limit?: number): Row[] => {
62+
const rows = Array.from(tableFor(o).values())
63+
.filter((r) => Object.entries(where ?? {}).every(([k, v]) => k.startsWith('$') || (r[k] ?? null) === (v ?? null)));
64+
// The caller's bound, after the filter, by presence.
65+
const page = typeof limit === 'number' ? rows.slice(0, limit) : rows;
66+
return page.map((r) => ({ ...r }));
67+
};
6568
let seq = 0;
6669
const driver = {
6770
name: 'store-sql-shaped', version: '0.0.0', supports: {},
6871
async connect(): Promise<void> {},
6972
async disconnect(): Promise<void> {},
7073
async checkHealth(): Promise<boolean> { return true; },
7174
async execute(): Promise<null> { return null; },
72-
async find(o: string, ast?: { where?: Row }): Promise<Row[]> { return run(o, ast?.where); },
73-
async findOne(o: string, ast?: { where?: Row }): Promise<Row | null> { return run(o, ast?.where)[0] ?? null; },
75+
async find(o: string, ast?: { where?: Row; limit?: number }): Promise<Row[]> { return run(o, ast?.where, ast?.limit); },
76+
async findOne(o: string, ast?: { where?: Row; limit?: number }): Promise<Row | null> { return run(o, ast?.where, ast?.limit)[0] ?? null; },
7477
async create(o: string, data: Row): Promise<Row> {
7578
seq += 1;
7679
const retired = o === CONTACT ? Object.fromEntries(RETIRED.map((c) => [c, null])) : {};

0 commit comments

Comments
 (0)