Skip to content

Releases: modem-dev/drizzle-scoped-db

v0.17.0

Choose a tag to compare

@codybrouwers codybrouwers released this 03 Sep 05:12
847df0f

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

  • InferSelection and scoped projections resolve through Drizzle's own SelectResultFields, so inference is identical before and after joins and whole-table entries resolve to rows. Unsupported leaf shapes are never, as in Drizzle, instead of unknown.
  • orderBy(...) and groupBy(...) accept Column | SQL | SQL.Aliased instead of any.
  • insert(...).values(...) and update(...).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(...), and selectDistinctOn(...) projections are constrained to Drizzle's SelectedFields, 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-orm

Verification

  • 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.0 with 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

Choose a tag to compare

@codybrouwers codybrouwers released this 12 Aug 18:55
9fdf24f

Fixed

  • Share one scoped select execution through synchronous post-where chaining, so one awaited query executes once instead of once per chained modifier.

Install

npm install @modem-dev/drizzle-scoped-db@0.16.0 drizzle-orm

Verification

  • 140 tests passed with 100% statement, branch, function, and line coverage.
  • The committed release benchmark gate passed against 0.15.0 with no accepted regressions.

v0.15.0

Choose a tag to compare

@codybrouwers codybrouwers released this 12 Aug 18:45
f7318ac

Added

  • Scope nested relational with includes 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 with includes on the callback/SQL API are now scoped instead of rejected. The Drizzle 1.0 RQBv2 object-filter API still fails closed on nested with until 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-db scope.

Install

npm install @modem-dev/drizzle-scoped-db@0.15.0 drizzle-orm

v0.14.0

Choose a tag to compare

@benvinegar benvinegar released this 19 Jul 16:16
018f870

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 with insertKey: false or updateKey: false.

Changed

  • Common single-column rules no longer need insertKey; Drizzle table metadata maps workspaceId: text("workspace_id") to the workspaceId insert/update payload key automatically.

v0.13.0

Choose a tag to compare

@benvinegar benvinegar released this 07 Jul 20:17
87dc6da

Breaking changes

  • This pre-1.0 minor release intentionally removes defineScopedTable(...) and ScopedTableRule from the public entrypoint. Prefer declarative scopeByColumn(...) / scopeByPredicate(...) rules, or use an explicit unsafe escape for bespoke query paths.
  • Remove the legacy hasScopeInConflictTarget custom-rule hook. Scoped PostgreSQL/SQLite upserts now derive their conflict-update guard from the rule's injected where(scopeValue) predicate and attach it to setWhere.

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 to undefined and producing always-empty guards. Use the single-column form for primitive scopes or supply an explicit value resolver.

v0.12.0

Choose a tag to compare

@benvinegar benvinegar released this 05 Jul 06:53
4f132f6

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

Choose a tag to compare

@benvinegar benvinegar released this 01 Jul 04:33
14cfc99

What's new

  • Added Drizzle 1.0 RQBv2 relational object-filter scoping for scopeByColumn rules.
  • RQBv2 relational queries now inject the active scope into object filters and fail closed for unsupported where shapes or custom rules without RQBv2 object-filter support.

Changed

  • pnpm build now cleans dist and 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

Choose a tag to compare

@benvinegar benvinegar released this 30 Jun 21:32
893ef0e

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

Choose a tag to compare

@benvinegar benvinegar released this 30 Jun 21:32
68d33f8

What's new

  • Scoped PostgreSQL/SQLite .onConflictDoUpdate(...) now injects the table rule's where(scopeValue) predicate into setWhere, 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 execute on 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

Choose a tag to compare

@benvinegar benvinegar released this 30 Jun 21:32
5908a8f

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

  • createScopedDb now 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.
  • InferSelection preserves sql<T> fragments, aliased SQL fragments, and nested selection objects, and falls back to unknown for unrecognized leaves.
  • Scoped .leftJoin(...) and .innerJoin(...) now accept SQL | undefined for the join condition.

Fixed

  • Scoped .values(...) and .set(...) payloads now accept Drizzle sql template expressions for individual column values.
  • .$unsafeUnscoped() conflict/upsert chains now preserve table-precise .returning(...) row types.