Releases: modem-dev/drizzle-scoped-db
Releases · modem-dev/drizzle-scoped-db
Release list
v0.17.0
Fixed
- Explicit scoped projections preserve nullable column types, including nested selection objects.
- Left-joined columns in explicit projections are nullable, matching Drizzle, including nested objects from the optional table.
- Whole-row
select()with.leftJoin(...)/.innerJoin(...)is typed as Drizzle's nested per-table rows with left-joined tables nullable, instead of flat root rows.
Changed
InferSelectionand scoped projections resolve through Drizzle's ownSelectResultFields, so inference is identical before and after joins and whole-table entries resolve to rows. Unsupported leaf shapes arenever, as in Drizzle, instead ofunknown.orderBy(...)andgroupBy(...)acceptColumn | SQL | SQL.Aliasedinstead ofany.insert(...).values(...)andupdate(...).set(...)payloads use the dialect's own Drizzle types (PgInsertValue,SQLiteInsertValue,MySqlInsertValue, and the matching update set sources), selected by the table's dialect, so placeholders and column references are accepted exactly as in raw Drizzle.select(...),selectDistinct(...), andselectDistinctOn(...)projections are constrained to Drizzle'sSelectedFields, so non-selection objects are rejected at compile time.
These are type-only changes. Generated SQL and runtime behavior are unchanged. Callers may see new compile errors where a left-joined field was used without a null check or where a projection contained a non-Drizzle value; both point at code that was already wrong at runtime.
Install
npm install @modem-dev/drizzle-scoped-db@0.17.0 drizzle-ormVerification
- 151 tests passed with 100% statement, branch, function, and line coverage on the locked and Drizzle 1.0 RC matrices.
- The release benchmark gate passed against
0.16.0with no accepted regressions. - The new type-check benchmark gate passed against
0.16.0: type count +17.1%, instantiation count +16.5%, under the +20% threshold.
v0.16.0
Fixed
- Share one scoped select execution through synchronous post-
wherechaining, so one awaited query executes once instead of once per chained modifier.
Install
npm install @modem-dev/drizzle-scoped-db@0.16.0 drizzle-ormVerification
- 140 tests passed with 100% statement, branch, function, and line coverage.
- The committed release benchmark gate passed against
0.15.0with no accepted regressions.
v0.15.0
Added
- Scope nested relational
withincludes on the callback/SQL relational query API (Drizzle 0.45). Scoped included relations now receive their own scope predicate recursively and fail closed when the relation or predicate cannot be resolved.
Changed
- Relational
withincludes on the callback/SQL API are now scoped instead of rejected. The Drizzle 1.0 RQBv2 object-filter API still fails closed on nestedwithuntil nested object-filter injection is supported. - The npm package is published as
@modem-dev/drizzle-scoped-db. Use this package name instead of the former@modemdev/drizzle-scoped-dbscope.
Install
npm install @modem-dev/drizzle-scoped-db@0.15.0 drizzle-ormv0.14.0
Breaking changes
scopeByColumn(table, table.column)now infers insert/update validation keys from the table property by default. Rules that previously scoped reads only will now reject cross-scope insert/update payloads unless validation is disabled explicitly withinsertKey: falseorupdateKey: false.
Changed
- Common single-column rules no longer need
insertKey; Drizzle table metadata mapsworkspaceId: text("workspace_id")to theworkspaceIdinsert/update payload key automatically.
v0.13.0
Breaking changes
- This pre-1.0 minor release intentionally removes
defineScopedTable(...)andScopedTableRulefrom the public entrypoint. Prefer declarativescopeByColumn(...)/scopeByPredicate(...)rules, or use an explicit unsafe escape for bespoke query paths. - Remove the legacy
hasScopeInConflictTargetcustom-rule hook. Scoped PostgreSQL/SQLite upserts now derive their conflict-update guard from the rule's injectedwhere(scopeValue)predicate and attach it tosetWhere.
Added
- Extend
scopeByColumn(...)to accept composite column scopes, deriving guard predicate injection, insert/update validation, strict SQL validation, and RQBv2 object filters from one declaration. - Add
scopeByPredicate(...)for one or more non-equality predicates such as soft deletes, with strict SQL validation derived from declared columns.
Changed
- Simplify the README API docs by moving advanced wrapper options out of the primary path.
- Throw a clear error when a
scopeByColumn(...)column map's default resolver receives a primitive scope value, instead of silently resolving toundefinedand producing always-empty guards. Use the single-column form for primitive scopes or supply an explicitvalueresolver.
v0.12.0
Highlights
- Added broader real-driver PostgreSQL and SQLite integration coverage for joins, distinct selects, mutations, transactions, and guarded builder surfaces.
- Documented strict mode as syntactic scope-context validation; injected predicates remain the authoritative runtime guard.
- Fixed several fail-closed guardrails around nested relational
with, custom rules without predicates, cached rule indexes, and sync-driver mutation/transaction behavior.
Validation
- CI passed for locked and RC Drizzle matrices.
- Release benchmark gate passed with no material regressions.
v0.11.0
What's new
- Added Drizzle 1.0 RQBv2 relational object-filter scoping for
scopeByColumnrules. - RQBv2 relational queries now inject the active scope into object filters and fail closed for unsupported
whereshapes or custom rules without RQBv2 object-filter support.
Changed
pnpm buildnow cleansdistand the TypeScript build-info cache before compiling, preventing stale local package artifacts after source files move or are deleted.
Validation
- Release benchmark gate passed.
- Validated against locked Drizzle 0.45.2 and Drizzle 1.0 RC.
v0.10.1
What's fixed
- Restores strict relational
db.query.*where-callback scope detection when schema keys differ from SQL table names. - Prevents false missing-scope errors for correctly scoped relational queries.
This is a patch release for the relational strict-mode regression introduced in 0.10.0.
v0.10.0
What's new
- Scoped PostgreSQL/SQLite
.onConflictDoUpdate(...)now injects the table rule'swhere(scopeValue)predicate intosetWhere, so cross-scope conflicts safely no-op.
Changed
- Relaxed scoped PostgreSQL/SQLite
.onConflictDoUpdate(...)conflict-target validation. Any conflict target is allowed while insert/update payload validators still run and scope-column reassignment still throws. - Stopped exposing raw
executeon scoped wrappers; use_unsafeUnscopedDb.execute(...)when intentionally running raw SQL. - Reject aliases of scoped tables unless the alias has its own explicit scoped rule, preventing aliases from silently bypassing rule lookup.
Fixed
- Prevent scoped insert/update/delete result chaining from leaking raw Drizzle builders through
.returning(), a second.where(...), or$dynamic().
v0.8.0
What's new
- Forwards dialect-native terminal methods through scoped mutation results when supported by the underlying builder:
.returning(...)on scoped insert/update/delete for Postgres and SQLite..$returningId()on scoped inserts for MySQL.
- Adds
.$unsafeUnscoped()on scoped insert results as a loud, local escape for explicitly audited conflict/upsert chains. - Exposes
.groupBy(...)and.having(...)on scoped select query builders.
Changed
createScopedDbnow returns an explicit scoped wrapper type instead of the raw database type.- Scoped
.returning(...)now infers row types from the target table and projection columns. InferSelectionpreservessql<T>fragments, aliased SQL fragments, and nested selection objects, and falls back tounknownfor unrecognized leaves.- Scoped
.leftJoin(...)and.innerJoin(...)now acceptSQL | undefinedfor the join condition.
Fixed
- Scoped
.values(...)and.set(...)payloads now accept Drizzlesqltemplate expressions for individual column values. .$unsafeUnscoped()conflict/upsert chains now preserve table-precise.returning(...)row types.