You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(deps): update dependency drizzle-orm to ^0.45.0 [security] - #146
Drizzle ORM improperly escaped quoted SQL identifiers in its dialect-specific escapeName() implementations. In affected versions, embedded identifier delimiters were not escaped before the identifier was wrapped in quotes or backticks.
As a result, applications that pass attacker-controlled input to APIs that construct SQL identifiers or aliases, such as sql.identifier(), .as(), may allow an attacker to terminate the quoted identifier and inject SQL.
Affected components
The issue affects the identifier escaping logic used by the PostgreSQL, MySQL, SQLite, SingleStore, and Gel dialects.
Impact
This issue only affects applications that pass untrusted runtime input into identifier or alias construction. Common examples include dynamic sorting, dynamic report builders, and CTE or alias names derived from request parameters.
Depending on the database dialect, query context, and database permissions, successful exploitation may enable blind or direct data disclosure, schema enumeration, query manipulation, privilege escalation, or destructive operations.
Applications that use only static schema objects, or that strictly map user input through an allowlist of known column or alias names, are not affected.
Details
In affected versions, escapeName() wrapped the identifier but did not escape the quote delimiter inside the identifier value:
PostgreSQL / SQLite / Gel: " was not doubled to ""
MySQL / SingleStore: ` was not doubled to ``
Because of this, crafted input containing the dialect-specific identifier delimiter could break out of the quoted identifier and be interpreted as SQL syntax.
A representative vulnerable pattern is dynamic sorting using untrusted input:
Fixed sql.identifier(), sql.as() escaping issues. Previously all the values passed to this functions were not properly escaped
causing a possible SQL Injection (CWE-89) vulnerability
Starting from this version, we’ve introduced a new DrizzleQueryError that wraps all errors from database drivers and provides a set of useful information:
A proper stack trace to identify which exact Drizzle query failed
The generated SQL string and its parameters
The original stack trace from the driver that caused the DrizzleQueryError
Drizzle cache module
Drizzle sends every query straight to your database by default. There are no hidden actions, no automatic caching or invalidation - you’ll always see exactly what runs. If you want caching, you must opt in.
By default, Drizzle uses a explicit caching strategy (i.e. global: false), so nothing is ever cached unless you ask. This prevents surprises or hidden performance traps in your application. Alternatively, you can flip on all caching (global: true) so that every select will look in cache first.
Out first native integration was built together with Upstash team and let you natively use upstash as a cache for your drizzle queries
import{upstashCache}from"drizzle-orm/cache/upstash";import{drizzle}from"drizzle-orm/...";constdb=drizzle(process.env.DB_URL!,{cache: upstashCache({// 👇 Redis credentials (optional — can also be pulled from env vars)url: '<UPSTASH_URL>',token: '<UPSTASH_TOKEN>',// 👇 Enable caching for all queries by default (optional)global: true,// 👇 Default cache behavior (optional)config: {ex: 60}})});
You can also implement your own cache, as Drizzle exposes all the necessary APIs, such as get, put, mutate, etc.
You can find full implementation details on the website
importKeyvfrom"keyv";exportclassTestGlobalCacheextendsCache{privateglobalTtl: number=1000;// This object will be used to store which query keys were used// for a specific table, so we can later use it for invalidation.privateusedTablesPerKey: Record<string,string[]>={};constructor(privatekv: Keyv=newKeyv()){super();}// For the strategy, we have two options:// - 'explicit': The cache is used only when .$withCache() is added to a query.// - 'all': All queries are cached globally.// The default behavior is 'explicit'.overridestrategy(): "explicit"|"all"{return"all";}// This function accepts query and parameters that cached into key param,// allowing you to retrieve response values for this query from the cache.overrideasyncget(key: string): Promise<any[]|undefined>{
...
}// This function accepts several options to define how cached data will be stored:// - 'key': A hashed query and parameters.// - 'response': An array of values returned by Drizzle from the database.// - 'tables': An array of tables involved in the select queries. This information is needed for cache invalidation.//// For example, if a query uses the "users" and "posts" tables, you can store this information. Later, when the app executes// any mutation statements on these tables, you can remove the corresponding key from the cache.// If you're okay with eventual consistency for your queries, you can skip this option.overrideasyncput(key: string,response: any,tables: string[],config?: CacheConfig,): Promise<void>{
...
}// This function is called when insert, update, or delete statements are executed.// You can either skip this step or invalidate queries that used the affected tables.//// The function receives an object with two keys:// - 'tags': Used for queries labeled with a specific tag, allowing you to invalidate by that tag.// - 'tables': The actual tables affected by the insert, update, or delete statements,// helping you track which tables have changed since the last cache update.overrideasynconMutate(params: {tags: string|string[];tables: string|string[]|Table<any>|Table<any>[];}): Promise<void>{
...
}}
Added drizzle connection attributes to SingleStore's driver instances
Fixes
Removed unsupported by dialect full join from MySQL select api
Forced Gel columns to always have explicit schema & table prefixes due to potential errors caused by lack of such prefix in subquery's selection when there's already a column bearing same name in context
Added missing export for PgTextBuilderInitial type
Removed outdated IfNotImported type check from SingleStore driver initializer
Fixed incorrect type inferrence for insert and update models with non-strict tsconfigs (#2654)
When importing from drizzle-orm using custom loaders, you may encounter issues such as: SyntaxError: The requested module 'drizzle-orm' does not provide an export named 'eq'
This issue arose because there were duplicated exports in drizzle-orm. To address this, we added a set of tests that checks every file in drizzle-orm to ensure all exports are valid. These tests will fail if any new duplicated exports appear.
In this release, we’ve removed all duplicated exports, so you should no longer encounter this issue.
pgEnum and mysqlEnum now can accept both strings and TS enums
If you provide a TypeScript enum, all your types will be inferred as that enum - so you can insert and retrieve enum values directly. If you provide a string union, it will work as before.
bigint, number modes for SQLite, MySQL, PostgreSQL, SingleStoredecimal & numeric column types
Changed behavior of sql-js query preparation to query prebuild instead of db-side prepare due to need to manually free prepared queries, removed .free() method
Fixed MySQL, SingleStorevarchar allowing not specifying length in config
Added Gel dialect support and gel-js client support
Drizzle is getting a new Gel dialect with its own types and Gel-specific logic. In this first iteration, almost all query-building features have been copied from the PostgreSQL dialect since Gel is fully PostgreSQL-compatible. The only change in this iteration is the data types. The Gel dialect has a different set of available data types, and all mappings for these types have been designed to avoid any extra conversions on Drizzle's side. This means you will insert and select exactly the same data as supported by the Gel protocol.
Drizzle + Gel integration will work only through drizzle-kit pull. Drizzle won't support generate, migrate, or push features in this case. Instead, drizzle-kit is used solely to pull the Drizzle schema from the Gel database, which can then be used in your drizzle-orm queries.
The Gel + Drizzle workflow:
Use the gel CLI to manage your schema.
Use the gel CLI to generate and apply migrations to the database.
Use drizzle-kit to pull the Gel database schema into a Drizzle schema.
Use drizzle-orm with gel-js to query the Gel database.
Here is a small example of how to connect to Gel using Drizzle:
// Make sure to install the 'gel' package import{drizzle}from"drizzle-orm/gel";import{createClient}from"gel";constgelClient=createClient();constdb=drizzle({client: gelClient});constresult=awaitdb.execute('select 1');
You can now use the new Bun SQL driver released in Bun v1.2.0 with Drizzle
In version 1.2.0, Bun has issues with executing concurrent statements, which may lead to errors if you try to run several queries simultaneously.
We've created a github issue that you can track. Once it's fixed, you should no longer encounter any such errors on Bun's SQL side
json and jsonb inserts and selects currently perform an additional JSON.stringify on the Bun SQL side. Once this is removed, they should work properly. You can always use custom types and redefine the mappers to and from the database.
datetime, date, and timestamp will not work properly when using mode: string in Drizzle. This is due to Bun's API limitations, which prevent custom parsers for queries. As a result, Drizzle cannot control the response sent from Bun SQL to Drizzle. Once this feature is added to Bun SQL, it should work as expected.
constusers=pgTable('users',{id: serial('id').primaryKey(),name: text('name').notNull(),});constsq=db.$with('sq',{userId: users.id,data: {name: users.name,},}).as(sql`select * from ${users} where ${users.name} = 'John'`);constresult=awaitdb.with(sq).select().from(sq);
New tables in /neon import
In this release you can use neon_identity schema and users_sync table inside this schema by just importing it from /neon
// "drizzle-orm/neon"constneonIdentitySchema=pgSchema('neon_identity');/** * Table schema of the `users_sync` table used by Neon Identity. * This table automatically synchronizes and stores user data from external authentication providers. * * @schema neon_identity * @table users_sync */exportconstusersSync=neonIdentitySchema.table('users_sync',{rawJson: jsonb('raw_json').notNull(),id: text().primaryKey().notNull(),name: text(),email: text(),createdAt: timestamp('created_at',{withTimezone: true,mode: 'string'}),deletedAt: timestamp('deleted_at',{withTimezone: true,mode: 'string'}),});
In MySQL, the statements USE INDEX, FORCE INDEX, and IGNORE INDEX are hints used in SQL queries to influence how the query optimizer selects indexes. These hints provide fine-grained control over index usage, helping optimize performance when the default behavior of the optimizer is not ideal.
Use Index
The USE INDEX hint suggests to the optimizer which indexes to consider when processing the query. The optimizer is not forced to use these indexes but will prioritize them if they are suitable.
The IGNORE INDEX hint tells the optimizer to avoid using specific indexes for the query. MySQL will consider all other indexes (if any) or perform a full table scan if necessary.
The FORCE INDEX hint forces the optimizer to use the specified index(es) for the query. If the specified index cannot be used, MySQL will not fall back to other indexes; it might resort to a full table scan instead.
A few internal types were changed and extra generic types for length of column types were added in this release. It won't affect anyone, unless you are using those internal types for some custom wrappers, logic, etc. Here is a list of all types that were changed, so if you are relying on those, please review them before upgrading
MySqlCharBuilderInitial
MySqlVarCharBuilderInitial
PgCharBuilderInitial
PgArrayBuilder
PgArray
PgVarcharBuilderInitial
PgBinaryVectorBuilderInitial
PgBinaryVectorBuilder
PgBinaryVector
PgHalfVectorBuilderInitial
PgHalfVectorBuilder
PgHalfVector
PgVectorBuilderInitial
PgVectorBuilder
PgVector
SQLiteTextBuilderInitial
New Features
Added new function getViewSelectedFields
Added $inferSelect function to views
Added InferSelectViewModel type for views
Added isView function
Validator packages updates
drizzle-zod has been completely rewritten. You can find detailed information about it here
drizzle-valibot has been completely rewritten. You can find detailed information about it here
drizzle-typebox has been completely rewritten. You can find detailed information about it here
Thanks to @L-Mario564 for making more updates than we expected to be shipped in this release. We'll copy his message from a PR regarding improvements made in this release:
Output for all packages are now unminified, makes exploring the compiled code easier when published to npm.
Smaller footprint. Previously, we imported the column types at runtime for each dialect, meaning that for example, if you're just using Postgres then you'd likely only have drizzle-orm and drizzle-orm/pg-core in the build output of your app; however, these packages imported all dialects which could lead to mysql-core and sqlite-core being bundled as well even if they're unused in your app. This is now fixed.
Slight performance gain. To determine the column data type we used the is function which performs a few checks to ensure the column data type matches. This was slow, as these checks would pile up every quickly when comparing all data types for many fields in a table/view. The easier and faster alternative is to simply go off of the column's columnType property.
Some changes had to be made at the type level in the ORM package for better compatibility with drizzle-valibot.
And a set of new features
createSelectSchema function now also accepts views and enums.
New function: createUpdateSchema, for use in updating queries.
New function: createSchemaFactory, to provide more advanced options and to avoid bloating the parameters of the other schema functions
Thanks to the SingleStore team for creating a PR with all the necessary changes to support the MySQL-compatible part of SingleStore. You can already start using it with Drizzle. The SingleStore team will also help us iterate through updates and make more SingleStore-specific features available in Drizzle
🎉 SQLite Durable Objects driver is now available in Drizzle
You can now query SQLite Durable Objects in Drizzle!
For the full example, please check our Get Started Section
/// <reference types="@cloudflare/workers-types" />import{drizzle,DrizzleSqliteDODatabase}from'drizzle-orm/durable-sqlite';import{DurableObject}from'cloudflare:workers'import{migrate}from'drizzle-orm/durable-sqlite/migrator';importmigrationsfrom'../drizzle/migrations';import{usersTable}from'./db/schema';exportclassMyDurableObject1extendsDurableObject{storage: DurableObjectStorage;db: DrizzleSqliteDODatabase<any>;constructor(ctx: DurableObjectState,env: Env){super(ctx,env);this.storage=ctx.storage;this.db=drizzle(this.storage,{logger: false});}asyncmigrate(){migrate(this.db,migrations);}asyncinsert(user: typeofusersTable.$inferInsert){awaitthis.db.insert(usersTable).values(user);}asyncselect(){returnthis.db.select().from(usersTable);}}exportdefault{/** * This is the standard fetch handler for a Cloudflare Worker * * @param request - The request submitted to the Worker from the client * @param env - The interface to reference bindings declared in wrangler.toml * @param ctx - The execution context of the Worker * @returns The response to be sent back to the client */asyncfetch(request: Request,env: Env): Promise<Response>{constid: DurableObjectId=env.MY_DURABLE_OBJECT1.idFromName('durable-object');conststub=env.MY_DURABLE_OBJECT1.get(id);awaitstub.migrate();awaitstub.insert({name: 'John',age: 30,email: 'john@example.com',})console.log('New user created!')constusers=awaitstub.select();console.log('Getting all users from the database: ',users)returnnewResponse();}}
[!NOTE] drizzle-seed can only be used with drizzle-orm@0.36.4 or higher. Versions lower than this may work at runtime but could have type issues and identity column issues, as this patch was introduced in drizzle-orm@0.36.4
By default, the seed function will create 10 entities.
However, if you need more for your tests, you can specify this in the seed options object
awaitseed(db,schema,{count: 1000});
seed
If you need a seed to generate a different set of values for all subsequent runs, you can define a different number
in the seed option. Any new number will generate a unique set of values
If you want to force you own values for GENERATED ALWAYS AS IDENTITY columns, you can use OVERRIDING SYSTEM VALUE
As PostgreSQL docs mentions
In an INSERT command, if ALWAYS is selected, a user-specified value is only accepted if the INSERT statement specifies OVERRIDING SYSTEM VALUE. If BY DEFAULT is selected, then the user-specified value takes precedence
Using this API, Drizzle will send you an auth token to authorize your query. It can be used with any query available in Drizzle by simply adding .$withAuth() before it. This token will be used for a specific query
Support for UPDATE ... FROM in PostgreSQL and SQLite
As the SQLite documentation mentions:
[!NOTE]
The UPDATE-FROM idea is an extension to SQL that allows an UPDATE statement to be driven by other tables in the database.
The "target" table is the specific table that is being updated. With UPDATE-FROM you can join the target table
against other tables in the database in order to help compute which rows need updating and what
the new values should be on those rows
Similarly, the PostgreSQL documentation states:
[!NOTE]
A table expression allowing columns from other tables to appear in the WHERE condition and update expressions
Drizzle also supports this feature starting from this version
Support for INSERT INTO ... SELECT in all dialects
As the SQLite documentation mentions:
[!NOTE]
The second form of the INSERT statement contains a SELECT statement instead of a VALUES clause.
A new entry is inserted into the table for each row of data returned by executing the SELECT statement.
If a column-list is specified, the number of columns in the result of the SELECT must be the same as
the number of items in the column-list. Otherwise, if no column-list is specified, the number of
columns in the result of the SELECT must be the same as the number of columns in the table.
Any SELECT statement, including compound SELECTs and SELECT statements with ORDER BY and/or LIMIT clauses,
may be used in an INSERT statement of this form.
[!CAUTION]
To avoid a parsing ambiguity, the SELECT statement should always contain a WHERE clause, even if that clause is simply "WHERE true", if the upsert-clause is present. Without the WHERE clause, the parser does not know if the token "ON" is part of a join constraint on the SELECT, or the beginning of the upsert-clause.
As the PostgreSQL documentation mentions:
[!NOTE]
A query (SELECT statement) that supplies the rows to be inserted
And as the MySQL documentation mentions:
[!NOTE]
With INSERT ... SELECT, you can quickly insert many rows into a table from the result of a SELECT statement, which can select from one or many tables
Drizzle supports the current syntax for all dialects, and all of them share the same syntax. Let's review some common scenarios and API usage.
There are several ways to use select inside insert statements, allowing you to choose your preferred approach:
You can pass a query builder inside the select function.
You can use a query builder inside a callback.
You can pass an SQL template tag with any custom select query you want to use
With Drizzle, you can enable Row-Level Security (RLS) for any Postgres table, create policies with various options, and define and manage the roles those policies apply to.
Drizzle supports a raw representation of Postgres policies and roles that can be used in any way you want. This works with popular Postgres database providers such as Neon and Supabase.
In Drizzle, we have specific predefined RLS roles and functions for RLS with both database providers, but you can also define your own logic.
Enable RLS
If you just want to enable RLS on a table without adding policies, you can use .enableRLS()
As mentioned in the PostgreSQL documentation:
If no policy exists for the table, a default-deny policy is used, meaning that no rows are visible or can be modified.
Operations that apply to the whole table, such as TRUNCATE and REFERENCES, are not subject to row security.
To fully leverage RLS, you can define policies within a Drizzle table.
In PostgreSQL, policies should be linked to an existing table. Since policies are always associated with a specific table, we decided that policy definitions should be defined as a parameter of pgTable
There are situations where you need to link a policy to an existing table in your database.
The most common use case is with database providers like Neon or Supabase, where you need to add a policy
to their existing tables. In this case, you can use the .link() API
import{sql}from"drizzle-orm";import{pgPolicy}from"drizzle-orm/pg-core";import{authenticatedRole,realtimeMessages}from"drizzle-orm/supabase";exportconstpolicy=pgPolicy("authenticated role insert policy",{for: "insert",to: authenticatedRole,using: sql``,}).link(realtimeMessages);
Migrations
If you are using drizzle-kit to manage your schema and roles, there may be situations where you want to refer to roles that are not defined in your Drizzle schema. In such cases, you may want drizzle-kit to skip managing these roles without having to define each role in your drizzle schema and marking it with .existing().
In these cases, you can u
[!IMPORTANT]
✂ PR body was truncated to here.
Configuration
📅 Schedule: (UTC)
Branch creation
At any time (no schedule defined)
Automerge
At any time (no schedule defined)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
If you want to rebase/retry this PR, check this box
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
Jun 6, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
Jun 11, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
Jun 12, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
Jun 18, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
Jun 19, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
Jul 24, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
Aug 21, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
Aug 21, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
Aug 26, 2026
renovateBot
changed the title
fix(deps): update dependency drizzle-orm to ^0.45.0 [security]
fix(deps): update dependency drizzle-orm to ^0.45.2 [security]
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
^0.30.0→^0.45.0Warning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
Drizzle ORM has SQL injection via improperly escaped SQL identifiers
CVE-2026-39356 / GHSA-gpj5-g38j-94v9
More information
Details
Summary
Drizzle ORM improperly escaped quoted SQL identifiers in its dialect-specific
escapeName()implementations. In affected versions, embedded identifier delimiters were not escaped before the identifier was wrapped in quotes or backticks.As a result, applications that pass attacker-controlled input to APIs that construct SQL identifiers or aliases, such as
sql.identifier(),.as(), may allow an attacker to terminate the quoted identifier and inject SQL.Affected components
The issue affects the identifier escaping logic used by the PostgreSQL, MySQL, SQLite, SingleStore, and Gel dialects.
Impact
This issue only affects applications that pass untrusted runtime input into identifier or alias construction. Common examples include dynamic sorting, dynamic report builders, and CTE or alias names derived from request parameters.
Depending on the database dialect, query context, and database permissions, successful exploitation may enable blind or direct data disclosure, schema enumeration, query manipulation, privilege escalation, or destructive operations.
Applications that use only static schema objects, or that strictly map user input through an allowlist of known column or alias names, are not affected.
Details
In affected versions,
escapeName()wrapped the identifier but did not escape the quote delimiter inside the identifier value:"was not doubled to""`was not doubled to``Because of this, crafted input containing the dialect-specific identifier delimiter could break out of the quoted identifier and be interpreted as SQL syntax.
A representative vulnerable pattern is dynamic sorting using untrusted input:
Usage example:
v0.45.2Compare Source
sql.identifier(),sql.as()escaping issues. Previously all the values passed to this functions were not properly escapedcausing a possible SQL Injection (CWE-89) vulnerability
Thanks to @EthanKim88, @0x90sh and @wgoodall01 for reaching out to us with a reproduction and suggested fix
v0.45.1Compare Source
require()(#5107)v0.45.0Compare Source
$onUpdatenot handlingSQLvalues (fixes #2388, tests implemented by L-Mario564 in #2911)pgmappers not handlingDateinstances inbun-sql:postgresqldriver responses fordate,timestamptypes (fixes #4493)v0.44.7Compare Source
v0.44.6Compare Source
v0.44.5Compare Source
.one()indurable-sqlitesessionblobcolumnsblobcolumnsblobmappingv0.44.4Compare Source
v0.44.3Compare Source
$clientfor clients created by drizzle functionupdated_atcolumn to theneon_auth.users_synctable definition.v0.44.2Compare Source
tsconfig: #4535, #4457v0.44.1Compare Source
v0.44.0Compare Source
Error handling
Starting from this version, we’ve introduced a new
DrizzleQueryErrorthat wraps all errors from database drivers and provides a set of useful information:Drizzlequery failedDrizzle
cachemoduleDrizzle sends every query straight to your database by default. There are no hidden actions, no automatic caching or invalidation - you’ll always see exactly what runs. If you want caching, you must opt in.
By default, Drizzle uses a explicit caching strategy (i.e.
global: false), so nothing is ever cached unless you ask. This prevents surprises or hidden performance traps in your application. Alternatively, you can flip on all caching (global: true) so that every select will look in cache first.Out first native integration was built together with Upstash team and let you natively use
upstashas a cache for your drizzle queriesYou can also implement your own cache, as Drizzle exposes all the necessary APIs, such as get, put, mutate, etc.
You can find full implementation details on the website
For more usage example you can check our docs
v0.43.1Compare Source
Fixes
v0.43.0Compare Source
Features
cross join(#1414)left,inner,crossjoins toPostgreSQL,MySQL,Gel,SingleStoreSingleStore's driver instancesFixes
full joinfromMySQLselect apiGelcolumns to always have explicit schema & table prefixes due to potential errors caused by lack of such prefix in subquery's selection when there's already a column bearing same name in contextPgTextBuilderInitialtypeIfNotImportedtype check fromSingleStoredriver initializertsconfigs (#2654)nowaitflag (#3554)v0.42.0Compare Source
Features
Duplicate imports removal
When importing from
drizzle-ormusing custom loaders, you may encounter issues such as:SyntaxError: The requested module 'drizzle-orm' does not provide an export named 'eq'This issue arose because there were duplicated exports in
drizzle-orm. To address this, we added a set of tests that checks every file indrizzle-ormto ensure all exports are valid. These tests will fail if any new duplicated exports appear.In this release, we’ve removed all duplicated exports, so you should no longer encounter this issue.
pgEnumandmysqlEnumnow can accept both strings and TS enumsIf you provide a TypeScript enum, all your types will be inferred as that enum - so you can insert and retrieve enum values directly. If you provide a string union, it will work as before.
Improvements
inArrayacceptReadonlyArrayas a value - thanks @Zamiell@planetscale/database's execute - thanks @ayrtonInferEnumtype - thanks @totigmIssues closed
v0.41.0Compare Source
bigint,numbermodes forSQLite,MySQL,PostgreSQL,SingleStoredecimal&numericcolumn typessql-jsquery preparation to query prebuild instead of db-side prepare due to need to manually free prepared queries, removed.free()methodMySQL,SingleStorevarcharallowing not specifyinglengthin configMySQL,SingleStorebinary,varbinarydata\type mismatchesnumeric\decimaldata\type mismatches: #1290, #1453drizzle-studio+AWS Data Apiconnection issue: #3224isConfigutility function checking types of wrong fieldssupportBigNumbersin auto-createdmysql2driver instances1231(numeric[]),1115(timestamp[]),1185(timestamp_with_timezone[]),1187(interval[]),1182(date[]), preventing precision loss and data\type mismatchesSQLitebuffer-modeblobsometimes returningnumber[]v0.40.1Compare Source
Updates to
neon-httpfor@neondatabase/serverless@1.0.0- thanks @jawjStarting from this version, drizzle-orm will be compatible with both
@neondatabase/serverless<1.0 and >1.0v0.40.0Compare Source
New Features
Added
Geldialect support andgel-jsclient supportDrizzle is getting a new
Geldialect with its own types and Gel-specific logic. In this first iteration, almost all query-building features have been copied from thePostgreSQLdialect since Gel is fully PostgreSQL-compatible. The only change in this iteration is the data types. The Gel dialect has a different set of available data types, and all mappings for these types have been designed to avoid any extra conversions on Drizzle's side. This means you will insert and select exactly the same data as supported by the Gel protocol.Drizzle + Gel integration will work only through
drizzle-kit pull. Drizzle won't supportgenerate,migrate, orpushfeatures in this case. Instead, drizzle-kit is used solely to pull the Drizzle schema from the Gel database, which can then be used in yourdrizzle-ormqueries.The Gel + Drizzle workflow:
gelCLI to manage your schema.gelCLI to generate and apply migrations to the database.Here is a small example of how to connect to Gel using Drizzle:
and drizzle-gel schema definition
On the drizzle-kit side you can now use
dialect: "gel"For a complete Get Started tutorial you can use our new guides:
v0.39.3Compare Source
reactfrom peerDependenciesv0.39.2Compare Source
neon_identitytoneon_auth- thanks @pffigueiredov0.39.1Compare Source
aliasedTable()v0.39.0Compare Source
New features
Bun SQL driver support
You can now use the new Bun SQL driver released in Bun v1.2.0 with Drizzle
or you can use Bun SQL instance
Current Limitations:
jsonandjsonbinserts and selects currently perform an additionalJSON.stringifyon the Bun SQL side. Once this is removed, they should work properly. You can always use custom types and redefine the mappers to and from the database.datetime,date, andtimestampwill not work properly when usingmode: stringin Drizzle. This is due to Bun's API limitations, which prevent custom parsers for queries. As a result, Drizzle cannot control the response sent from Bun SQL to Drizzle. Once this feature is added to Bun SQL, it should work as expected.arraytypes currently have issues in Bun SQL.WITH now supports INSERT, UPDATE, DELETE and raw sql template
withandinsertwithandupdatewithanddeletewithandsqlNew tables in
/neonimportIn this release you can use
neon_identityschema andusers_synctable inside this schema by just importing it from/neonUtils and small improvements
getViewNameutil functionBug fixed and GitHub issue closed
v0.38.4Compare Source
vector- thanks @mitchwadairv0.38.3Compare Source
v0.38.2Compare Source
New features
USE INDEX,FORCE INDEXandIGNORE INDEXfor MySQLIn MySQL, the statements USE INDEX, FORCE INDEX, and IGNORE INDEX are hints used in SQL queries to influence how the query optimizer selects indexes. These hints provide fine-grained control over index usage, helping optimize performance when the default behavior of the optimizer is not ideal.
Use Index
The
USE INDEXhint suggests to the optimizer which indexes to consider when processing the query. The optimizer is not forced to use these indexes but will prioritize them if they are suitable.Ignore Index
The
IGNORE INDEXhint tells the optimizer to avoid using specific indexes for the query. MySQL will consider all other indexes (if any) or perform a full table scan if necessary.Force Index
The
FORCE INDEXhint forces the optimizer to use the specified index(es) for the query. If the specified index cannot be used, MySQL will not fall back to other indexes; it might resort to a full table scan instead.You can also combine those hints and use multiple indexes in a query if you need
v0.38.1Compare Source
v0.38.0Compare Source
Types breaking changes
A few internal types were changed and extra generic types for length of column types were added in this release. It won't affect anyone, unless you are using those internal types for some custom wrappers, logic, etc. Here is a list of all types that were changed, so if you are relying on those, please review them before upgrading
MySqlCharBuilderInitialMySqlVarCharBuilderInitialPgCharBuilderInitialPgArrayBuilderPgArrayPgVarcharBuilderInitialPgBinaryVectorBuilderInitialPgBinaryVectorBuilderPgBinaryVectorPgHalfVectorBuilderInitialPgHalfVectorBuilderPgHalfVectorPgVectorBuilderInitialPgVectorBuilderPgVectorSQLiteTextBuilderInitialNew Features
getViewSelectedFields$inferSelectfunction to viewsInferSelectViewModeltype for viewsisViewfunctionValidator packages updates
drizzle-zodhas been completely rewritten. You can find detailed information about it heredrizzle-valibothas been completely rewritten. You can find detailed information about it heredrizzle-typeboxhas been completely rewritten. You can find detailed information about it hereThanks to @L-Mario564 for making more updates than we expected to be shipped in this release. We'll copy his message from a PR regarding improvements made in this release:
And a set of new features
createSelectSchemafunction now also accepts views and enums.createUpdateSchema, for use in updating queries.createSchemaFactory, to provide more advanced options and to avoid bloating the parameters of the other schema functionsBug fixes
v0.37.0Compare Source
New Dialects
🎉
SingleStoredialect is now available in DrizzleThanks to the SingleStore team for creating a PR with all the necessary changes to support the MySQL-compatible part of SingleStore. You can already start using it with Drizzle. The SingleStore team will also help us iterate through updates and make more SingleStore-specific features available in Drizzle
You can check out our Getting started guides to try SingleStore!
New Drivers
🎉
SQLite Durable Objectsdriver is now available in DrizzleYou can now query SQLite Durable Objects in Drizzle!
For the full example, please check our Get Started Section
Bug fixes
v0.36.4Compare Source
New Package:
drizzle-seedFull Reference
The full API reference and package overview can be found in our official documentation
Basic Usage
In this example we will create 10 users with random names and ids
Options
countBy default, the
seedfunction will create 10 entities.However, if you need more for your tests, you can specify this in the seed options object
seedIf you need a seed to generate a different set of values for all subsequent runs, you can define a different number
in the
seedoption. Any new number will generate a unique set of valuesThe full API reference and package overview can be found in our official documentation
Features
Added
OVERRIDING SYSTEM VALUEapi to db.insert()If you want to force you own values for
GENERATED ALWAYS AS IDENTITYcolumns, you can useOVERRIDING SYSTEM VALUEAs PostgreSQL docs mentions
Added
.$withAuth()API for Neon HTTP driverUsing this API, Drizzle will send you an auth token to authorize your query. It can be used with any query available in Drizzle by simply adding
.$withAuth()before it. This token will be used for a specific queryExamples
Bug Fixes
v0.36.3Compare Source
New Features
Support for
UPDATE ... FROMin PostgreSQL and SQLiteAs the SQLite documentation mentions:
Similarly, the PostgreSQL documentation states:
Drizzle also supports this feature starting from this version
For example, current query:
Will generate this sql
You can also alias tables that are joined (in PG, you can also alias the updating table too).
Will generate this sql
In PostgreSQL, you can also return columns from the joined tables.
Will generate this sql
Support for
INSERT INTO ... SELECTin all dialectsAs the SQLite documentation mentions:
As the PostgreSQL documentation mentions:
And as the MySQL documentation mentions:
Drizzle supports the current syntax for all dialects, and all of them share the same syntax. Let's review some common scenarios and API usage.
There are several ways to use select inside insert statements, allowing you to choose your preferred approach:
Query Builder
Callback
SQL template tag
v0.36.2Compare Source
New Features
Bug and typo fixes
Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter
Fixed .generated behavior with non-strict tsconfig
Fix Drizzle ORM for expo-sqlite
Fixed lack of schema name on columns in sql
fix: Adjust neon http driver entity kind
Export PgIntegerBuilderInitial type
[MySQL] Correct $returningId() implementation to correctly store selected fields
v0.36.1Compare Source
Bug Fixes
v0.36.0Compare Source
New Features
The third parameter in Drizzle ORM becomes an array
Instead of this
You can now do this
Row-Level Security (RLS)
With Drizzle, you can enable Row-Level Security (RLS) for any Postgres table, create policies with various options, and define and manage the roles those policies apply to.
Drizzle supports a raw representation of Postgres policies and roles that can be used in any way you want. This works with popular Postgres database providers such as
NeonandSupabase.In Drizzle, we have specific predefined RLS roles and functions for RLS with both database providers, but you can also define your own logic.
Enable RLS
If you just want to enable RLS on a table without adding policies, you can use
.enableRLS()As mentioned in the PostgreSQL documentation:
Roles
Currently, Drizzle supports defining roles with a few different options, as shown below. Support for more options will be added in a future release.
If a role already exists in your database, and you don’t want drizzle-kit to ‘see’ it or include it in migrations, you can mark the role as existing.
Policies
To fully leverage RLS, you can define policies within a Drizzle table.
Example of pgPolicy with all available properties
Link Policy to an existing table
There are situations where you need to link a policy to an existing table in your database.
The most common use case is with database providers like
NeonorSupabase, where you need to add a policyto their existing tables. In this case, you can use the
.link()APIMigrations
If you are using drizzle-kit to manage your schema and roles, there may be situations where you want to refer to roles that are not defined in your Drizzle schema. In such cases, you may want drizzle-kit to skip managing these roles without having to define each role in your drizzle schema and marking it with
.existing().In these cases, you can u
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.