Skip to content

Commit 978def3

Browse files
committed
test(metadata-protocol): the served-content-hash pin's find double holds the caller's bound (#21207)
Claude-Session: https://claude.ai/code/session_01VvcEokUG1tvVxkceYfR5XB Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9d3a09c commit 978def3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/metadata-protocol/src/protocol.served-content-hash.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,14 @@ function makeEngine(opts: { provider?: boolean } = {}) {
101101
if (table === 'sys_metadata_history') return historyRows.find((h) => matchesWhere(h, o.where)) ?? null;
102102
return findRow(o.where)?.row ?? null;
103103
},
104-
async find(table: string, o: { where?: Record<string, unknown> } = {}) {
105-
if (table === 'sys_metadata_audit') return auditRows.filter((a) => matchesWhere(a, o.where));
106-
if (table === 'sys_metadata_history') return historyRows.filter((h) => matchesWhere(h, o.where));
107-
return Array.from(rows.values()).filter((r) => matchesWhere(r, o.where));
104+
async find(table: string, o: { where?: Record<string, unknown>; limit?: number } = {}) {
105+
const matched = table === 'sys_metadata_audit'
106+
? auditRows.filter((a) => matchesWhere(a, o.where))
107+
: table === 'sys_metadata_history'
108+
? historyRows.filter((h) => matchesWhere(h, o.where))
109+
: Array.from(rows.values()).filter((r) => matchesWhere(r, o.where));
110+
// The caller's bound, applied after the filter, by presence.
111+
return typeof o?.limit === 'number' ? matched.slice(0, o.limit) : matched;
108112
},
109113
async insert(table: string, data: Record<string, unknown>) {
110114
nextId += 1;

0 commit comments

Comments
 (0)