Commit activity
Last 12 weeks · 10 commits
Community health
4 of 6 standards met
Recent PRs & issues
This PR introduces PostgreSQL Domain Support and enhances Check Constraint Integration with Drizzle-Zod, addressing issues #218, #3446, and #3520. Why this PR? End the Validation Duplication Nightmare Tired of maintaining duplicate validation logic? This PR eliminates the need to write the same rules in two places: 1. Database constraints (CHECK clauses, domains) 2. Application validation (Zod schemas, manual checks) Before 😩 Now 🎉 Key Benefits 🌟 1. Single Source of Truth Define validation rules once in your database schema - Drizzle automatically propagates them to Zod 2. DRY Principle Enforced Never accidentally update application validation without updating database constraints (or vice versa) 3. Type Safety from Edge to Edge Get Zod schemas that exactly match your database constraints, from API endpoints to UI forms 4. Schema Evolution Made Safe Changing a constraint in your migration? Zod validations automatically update when you regenerate types Real-World Impact 💸 For a medium-sized app with: 50 database tables 3-5 constraints per table 10+ API endpoints You'll eliminate 200-300 lines of manual Zod validation code and save 5-10 hours/month** on schema maintenance. Changes: PostgreSQL Domain Support What are Domains? Domains are user-defined data types that enforce constraints on existing PostgreSQL types. They help standardize column definitions and reuse validation rules across tables. Defining Domains in Drizzle Equivalent SQL: Key Features Full migration support for domain creation/alteration Domain-aware schema introspection Cross-schema domain support Automatic constraint validation during inserts/updates Changes: Check Constraint Integration with Drizzle-Zod Automatic Zod Validation Check constraints (both column-level and domain-based) now generate proper Zod validations: Supported Constraints Minimum/maximum values (integers, bigints, dates) String length limits Regular expression patterns Range checks (BETWEEN) Custom SQL expressions
v1.0.0-rc.6 Breaking changes: Drivers no longer configure output decoding in drivers' configurations - following configurations set by drizzle constructors were removed: from , transparent decoders from global from , per-query parser overrides from , , , , , , per-query from :exclamation: still overrides client's param serializers (client-wide, replacing user-configured ones) for (), (), (), () and their arrays: values are sent as - same as ' default for , , strings are sent as is to be parsed by the server - ' default re-encodes them via , which reads offset-less timestamps in process' local time, truncates microseconds and throws on values JS can't parse (, ) switches processing from to ISO string Driver config overrides were replaced with cast codecs for types: , : , , , , , , , , and their array versions (fixes #6290) , : , , , , , : integer-based codecs (, , , ) accept , and integer text, which makes them independent of safe integer modes ('s , 's , 's , 's ) :exclamation: Results of raw queries (, fields without a column's decoder) now honor driver's configuration , , servers no longer need to replicate drizzle's driver result type configurations (e.g. returning , , as strings via / ) :warning: Codecs only cover client options with predictable output (, , , , , ...). Custom parsing functions ('s / , ' , 's ) that change output of types drizzle doesn't cast still require custom codecs, e.g.: Changed (, ), () from plain objects to functions due to param wrapper functions only being accessible from drivers via Fixed in returning trailing zeroes for empty second fractions Bumped minimal supported version of peer dependency from to to match declarations of ; changed , peer dependency version requirements from to Changed shapes of dialect-specific , expressions () to match their dialects' functions: , , : now accepts any number of values (, , , , ) and emits instead of , which is a logical in , and is unsupported by before SQL Server 2025 , : - is now required ( is a syntax error); , accept , : now requires at least one of , ( is an error); is cast to () / () due to overload being picked by default; positions accept , : added regular expression overloads: POSIX regular expression () : - SQL regular expression () : - POSIX regular expression with in place of () : -> , emits instead of unsupported ; , accept : -> , emits instead of unsupported values and arguments are no longer encoded with the column's encoder - they are not expected to share the column's type Fixed subqueries selected as fields being inferred as non-nullable - a subquery can return no rows, so their values are now typed as . This also applies to such fields re-selected from views and subqueries built from these selections: cache now stores query results in a binary format instead of JSON, which turned values JSON can't represent into different types on cache hits. Results are encoded to a base64 string with a prefix - entries written by previous versions are treated as cache misses. Serialization can be replaced with the option: : is no longer read from or written to cache - it returns driver's run result instead of rows. Mutations executed by still invalidate cache Fixed failing to encode empty array params () of , , , , , , , serial types, , , columns (fixes #6566) Fixed , columns in mode returning strings when decodes as text (fixes #6566) Fixed , columns in mode returning strings since started ignoring set after client's construction Fixed empty multidimensional arrays being returned as Fixed narrowing columns to : : , , with (), plain , : columns () : , , , in mode () Fixed , enum columns narrowed by having typed as Fixed columns being typed with instead of , which made validators infer instead of the enum's values Fixed , , , in mode having instead of , which made validators generate string schemas for values Fixed validators inferring instead of enum members for columns of enums made from TS enums (, , ) Fixed without option breaking refine callbacks' parameter type inference () (fixes #5968) Fixed errors on , columns' params with , , , values and arrays starting with them () (fixes #6582) Fixed errors on , columns' params with top-level , , , values (fixes #6591) Fixed with errors on , columns' params (fixes #6132) Fixed , , , errors on , columns' params with , , values () Fixed type errors in emitted declarations with (fixes #5187): in projects without installed - general modules (, , ...) no longer reference driver packages' types (same for , , ) with on TypeScript 5.6 and older in codecs and 's Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6495 Thanks to @pintu544 for opening this pull request - https://github.com/drizzle-team/drizzle-orm/pull/6516 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6492 Thanks to @shaurya703 for opening this pull request - https://github.com/drizzle-team/drizzle-orm/pull/6518 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6557 Thanks to @tlq5l for opening this pull request - https://github.com/drizzle-team/drizzle-orm/pull/6561 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6472 Thanks to @Adnan-Husayn for opening this pull request with the proposed solution - https://github.com/drizzle-team/drizzle-orm/pull/6483 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6447 Thanks to @Saadanjum0, @drago1520 and @shreyanshj10 for opening those pull requests - https://github.com/drizzle-team/drizzle-orm/pull/6450, https://github.com/drizzle-team/drizzle-orm/pull/6449, https://github.com/drizzle-team/drizzle-orm/pull/6448 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6423 Thanks to @yousefissa for opening this pull request - https://github.com/drizzle-team/drizzle-orm/pull/6432 Fixed: https://github.com/drizzle-team/drizzle-orm/issues/6357 Thanks to @zhamann for opening this pull request - https://github.com/drizzle-team/drizzle-orm/pull/6358 Fixed: #4178 Thanks to @yyuneu for opening this pull request - #6226 Fixed: #6188. Thanks to @webdevsamran for opening this pull request Fixed: #6493 Thanks to @pintu544 and @shaurya703 for opening these pull requests - #6521, #6519 Fixed query buidlers dropping offset with value (fixes #6599) Fixed #6622 Fixed #6550 Fixed , , result type: -> Fixed #6531 , : can no longer be combined with as the result can't report updated rows' ids Fixed #6552: years past 9999 () are sent without the expanded-year sign: years before 1 AD (, ) are sent with the suffix: Fixed , , columns in mode decoding values that misreads: years 1 - 99 were read as two-digit years ( -> 1999) values past year 9999 were read in process' local time values with the suffix and with seconds-precision UTC offsets were decoded as Fixed , columns in mode being decoded as wrong dates or in sessions with non-ISO (fixes #6496) Fixed columns losing fractional seconds past milliseconds and columns (, modes) losing the suffix of values with fractional seconds: they are now selected as text instead of Data API's own formatting Fixed failing queries ( on the AWS Data API emulator) selecting values with years past 9999 or seconds-precision UTC offsets, and the , formatting losses above: , , columns are now selected as text Fixed #6625 Fixed #6534 Fixed #5992 Fixed #6501 Fixed #6593 Fixed #5712 Fixed transaction config allowing without Fixed () passing array elements to normalizer instead of skipping them Fixed [[BUG]: MySQL generate ignores onUpdateNow() for string-mode timestamp/datetime (rc.5)](https://github.com/drizzle-team/drizzle-orm/issues/6632) Fixed [[BUG]: MySQL generate creates child foreign key before its new parent unique index (rc.5)](https://github.com/drizzle-team/drizzle-orm/issues/6649) Fixed: [[BUG]: durable-sqlite migrate hides the error of a failed migration behind TransactionRollbackError](https://github.com/drizzle-team/drizzle-orm/issues/6468) Fixed elements of , array columns being passed into decoders\encoders instead of being kept as (fixes #6460): Fixed , , array elements being written as JSON instead of SQL Fixed: [[BUG]: SQLITE migration incorrectly uses ALTER table when adding a column with a non-constant default](https://github.com/drizzle-team/drizzle-orm/issues/6408) Fixed: [[BUG]: SQLite generate orders DROP TABLE alphabetically, so a parent can be dropped before the child that references it](https://github.com/drizzle-team/drizzle-orm/issues/6251) Fixed ignoring option Removed from PostgreSQL indexes. Since migrations run within a transaction and SQL statements using cannot be executed inside a transaction, could not be used no longer has on postgres indexes and the kit DDL no longer has the field on index rows. wrote format 9 with in every index row and in index deltas. The snapshot format now goes to 10 removes from format 9 base rows, index deltas and index sets. It drops an alter that set only and leaves footprints as they are The API takes the same steps for one state: , the state as a base snapshot, then and keep their names, so the changes are easy to find in review. They can be renamed after the review
Report hasn't been filed before. [x] I have verified that the bug I'm about to report hasn't been filed before. What version of are you using? 1.0.0-rc.6 preview from #6588 () What version of are you using? 1.0.0-rc.6 preview from #6588 () Other packages mssql@12.7.10 Describe the Bug Follow-up to #5992. On the rc.6 preview, with no longer crashes when a table in has a foreign key to a table outside it. But the generated still contains that foreign key, which points at a table that was never emitted, so the file doesn't compile. Steps to reproduce: Run , then type-check the output: Expected: only foreign keys whose source and target tables are both in the result are emitted (or the ones that point outside are dropped with a warning). Actual: gets , and is not declared. On our database (50 filtered tables out of 837) this leaves 210 errors across 89 missing tables. It looks like the result step in filters foreign keys only by their source table: Filtering also on the target table (, ) would fix it.
Recent fixes
This PR adds . It runs the ORM on Effect with from . The connector uses the codecs and the shape generator of the async Drizzle Postgres connector, so the driver decodes rows through the shape. The database also has , , and . and take Effects and pass them to and , as does with any Effect. A tuple of Effects gives a tuple of results, as in . fails with the first failure. Wrap an Effect in to get its failure as a value. Changes outside the new folder: The Effect query builders in (select, relational query, insert, update, delete) now get a shape from and pass it to , as the async builders do. , and the other Effect connectors have no shape generator, so they keep the same behavior. can skip the cache lookup. The new connector does that when is , that is inside and . The lookup is async, so without the skip a statement that started later could reach the pipelined connection first. A mutation still invalidates the cache after it runs. The other Effect connectors do not skip the lookup. exports , its and keep tuple types, and has a new overload for . The bulk preparation of the async moved into and , which both sessions use. The async behavior does not change. The dev dependency goes from 4.0.0 to 4.0.6 in drizzle-orm and integration-tests. uses 4.0.6, and two copies of break the types. The new test file runs the shared Effect Postgres suite and adds tests for , transaction snapshots, the migrator, , , the bulk methods and the statement order with a cache. It skips , as does. Locally, the effect-drizzle-postgres, postgres, effect-pg and effect-pglite files pass, except the tests. Those tests need , which I do not have, so CI has to check them for the new connector.
Remove . The workflow runs on every branch delete and has failed on all 146 runs in its history. It runs for 7 packages, but most branches have no dist-tag, because feature releases publish only through . The secret is also empty in these runs, and npm OIDC cannot remove dist-tags. The workflow removes only dist-tags, so no published versions are affected. Stale dist-tags stay on npm and can be removed by hand.
Repository: drizzle-team/drizzle-orm. Description: ORM Stars: 36276, Forks: 1771. Primary language: TypeScript. Languages: TypeScript (98.7%), JavaScript (1.3%). License: Apache-2.0. Homepage: https://orm.drizzle.team Topics: bunjs, mysql, nodejs, orm, postgres, postgresql, sql, sqlite, turso, typescript. Latest release: 0.45.4 (1mo ago). Open PRs: 100, open issues: 1951. Last activity: 14h ago. Community health: 87%. Top contributors: AndriiSherman, dankochetov, L-Mario564, AlexBlokh, Sukairo-02, Angelelz, AleksandrSherman, OleksiiKH0240, RomanNabukhotnyi, realmikesolo and others.