Summary
Custom defineScopedTable(...) rules have only fake-builder success coverage, and custom RQBv2 relational support has failure coverage but no success-path coverage. Add integration/unit tests for composite custom rules, RQBv2 custom object-filter support, and custom error factory arguments.
Evidence
Relevant APIs:
defineScopedTable(...) in src/rules.ts
ScopedTableRule.relational.rqbV2 in src/types.ts
- RQBv2 merge/validation in
src/internal/relational/rqb-v2-adapter.ts
Current tests:
- fake-builder unit test for a composite custom rule;
- unit test that custom RQBv2 rules without object-filter support throw;
- custom error test checks full arguments for
missingWhere, but not every error factory argument shape.
Suggested tests
Real-driver composite custom rule
For Postgres and SQLite, define a rule scoped by { workspaceId, regionId }:
defineScopedTable(projects, {
where: (scope) => and(
eq(projects.workspaceId, scope.workspaceId),
eq(projects.regionId, scope.regionId),
),
validateInsert: (row, scope) =>
row.workspaceId === scope.workspaceId && row.regionId === scope.regionId,
validateUpdate: (payload, scope) =>
(!payload.workspaceId || payload.workspaceId === scope.workspaceId) &&
(!payload.regionId || payload.regionId === scope.regionId),
hasScopeInWhere: ...,
});
Assert real select/update/delete/upsert affect only rows matching both dimensions.
RQBv2 custom success path
Unit or integration where supported:
defineScopedTable(projects, {
queryName: "projectsTbl",
where: ...,
relational: {
rqbV2: {
where: (scope) => ({ workspaceId: scope.workspaceId, regionId: scope.regionId }),
hasScopeInWhere: (where) => /* require both keys */,
},
},
});
Assert:
- strict missing composite scope throws;
- valid object filter merges as
{ AND: [userWhere, scopedWhere] };
- returned rows are scoped correctly where integration is available.
Error factory arguments
Add assertions that custom factories receive correct values:
invalidInsert(tableName, offendingRow, scopeName, scopeValue)
invalidUpdate(tableName, offendingPayload, scopeName, scopeValue)
invalidConflictTarget(tableName, scopeName, scopeValue)
missingScope(tableName, scopeName, scopeValue)
Acceptance criteria
- Custom rule behavior is proven against at least one real driver.
- RQBv2 custom object-filter success path is covered.
- Error factory argument contracts are fully tested.
Summary
Custom
defineScopedTable(...)rules have only fake-builder success coverage, and custom RQBv2 relational support has failure coverage but no success-path coverage. Add integration/unit tests for composite custom rules, RQBv2 custom object-filter support, and custom error factory arguments.Evidence
Relevant APIs:
defineScopedTable(...)insrc/rules.tsScopedTableRule.relational.rqbV2insrc/types.tssrc/internal/relational/rqb-v2-adapter.tsCurrent tests:
missingWhere, but not every error factory argument shape.Suggested tests
Real-driver composite custom rule
For Postgres and SQLite, define a rule scoped by
{ workspaceId, regionId }:Assert real select/update/delete/upsert affect only rows matching both dimensions.
RQBv2 custom success path
Unit or integration where supported:
Assert:
{ AND: [userWhere, scopedWhere] };Error factory arguments
Add assertions that custom factories receive correct values:
invalidInsert(tableName, offendingRow, scopeName, scopeValue)invalidUpdate(tableName, offendingPayload, scopeName, scopeValue)invalidConflictTarget(tableName, scopeName, scopeValue)missingScope(tableName, scopeName, scopeValue)Acceptance criteria