Skip to content

Releases: drizzle-team/drizzle-orm

v1.0.0-rc.1

30 Apr 21:47
e2a6f87

Choose a tag to compare

v1.0.0-rc.1 Pre-release
Pre-release

v1.0.0-rc.1

⚠️ This release introduced a breaking change into our casing API(see below) and removes RQB v1 ._query for postgres

JIT mappers

Drizzle ORM now has an opt-in API for JIT(just in time compilated) mappers which make most expensive part of the db request pipeline(row mapping) as fast as humanly possible.

const db = drizzle({ ..., jit: true })

const query = db.select().from(users).prepare();
// ^ here drizzle generates a jit mapper which will then be reused during each invocation

server.get('users', (c) => {
  const users = await query.execute(); // as fast as using raw driver
  return c.json(users)
})

We've reworked internals of Drizzle ORM with the new system of codecs. Those are now in charge of normalising responses and requests for diffrent drivers across pg dialect. They helped us not only properly fix a set of data mapping issues but also massively improve performance by not doing unnecessary work.
We've seen a 25%-30% reduction in latency, while +800rps(14500->15300) in our benchmarks
Give it a go and let us know if everything works just fine!

Effect v4

drizzle-orm@1.0.0-rc.1 comes with native support for Effect v4 via:

import { PgClient } from '@effect/sql-pg';
import * as PgDrizzle from 'drizzle-orm/effect-postgres';
import * as Effect from 'effect/Effect';
import * as Redacted from 'effect/Redacted';
import { relations } from '../relations';

const connectionStr = Redacted.make(process.env['PG_CONNECTION_STRING']!);
const PgClientLive = PgClient.layer({
  url: connectionStr,
});

const DB = PgDrizzle.make({ relations }).pipe(Effect.provide(PgDrizzle.DefaultServices));
const program = Effect.gen(function*() {
  const db = yield* DB;

  const users = yield* db.select().from(usersTable);
}).pipe(Effect.provide(PgClientLive));

await Effect.runPromise(program);

New Casing API

⚠️ BREAKING CHANGE
In rc.1 we've finally reworked our legacy casing API of const db = drizzle({..., casing: "camel" }) which turned out to not be a proper solution, it required duplication in drizzle-orm instantiation and drizzle-kit config and introduced and set of endless bugs all around query builder chain. All of the above is now fixed with new API:

import * as d from "drizzle-orm/pg-core";

const users = d.snakeCase.table("users", {
  id: d.serial().primaryKey(),
  email: d.text().unique(),
  fullName: d.text(), // full_name in db
  createdAt: d.timestamp().defaultNow(), // created_at in db
})

// --- for namespaces/schemas you can use

const schema2 = d.camelCase.schema("schema2");

const usersInSchema2 = schema2.table("users", ...);
const ordersInSchema2 = schema2.table("orders", ...);
// ^ all entities in schema2 will be snake_cased


// --- all available entities
import { snakeCase, camelCase } from "drizzle-orm/pg-core";

snakeCase.view
snakeCase.materializedView
snakeCase.schema
snakeCase.table

camelCase.view
camelCase.materializedView
camelCase.schema
camelCase.table

New Netlify Database Driver

Note: The Netlify Database driver is developed and maintained by the Netlify team.

Installation:

npm install @netlify/database

Usage example:

import { drizzle } from 'drizzle-orm/netlify-db';

const db = drizzle();

const result = await db.execute('select 1');
import { drizzle } from 'drizzle-orm/netlify-db';

const db = drizzle(process.env.DATABASE_URL);

const result = await db.execute('select 1');
import { drizzle } from 'drizzle-orm/netlify-db';

// Explicit client — consumer controls the driver
const db = drizzle({ client: netlifyDbClient });

const result = await db.execute('select 1');

Bug fixes and improvements:

  • Codec system for postgres - resolves issues created by differences of data types returned by different drivers or different contexts of query (regular select, JSON object, postgres array). Currently only handles supported by drizzle constructors column types. (fixes #3018, #5090, #5287)
  • Optimized query mappers for postgres
  • Opt-in JIT-generated mappers for all dialects
  • Optimized RQBv2 mappers for all dialects
  • ⚠️ BREAKING CHANGE: Removed RQBv1 (db._query) from postgres
  • Moved pg array utils (makePgArray, parsePgArray) from drizzle-orm/pg-core/utils[/array] to drizzle-orm/pg-core/array
  • Simplified postgres sessions & prepared queries
  • Fixed neon-http bytea data corruption
  • Fixed bun-sql/postgres timestamp timezone truncation, json[b] data double stringification
  • ⚠️ BREAKING CHANGE: Reworked casing API - moved casing control from db instance to table \ view \ schema via import { snakeCase, camelCase } from "drizzle-orm/dialect-core", fixed #5112 #5282 #4181 #4209
  • Switched from Effect V3 to Effect V4 beta for effect-schema, effect-postgres (fixes #5414)

v1.0.0-rc.2

05 May 18:33
48e5406

Choose a tag to compare

v1.0.0-rc.2 Pre-release
Pre-release

Updates

  • Disabled default codec type selectors for custom columns (fixes #5711)
  • Сallback type overload for codec selector in custom pg columns (codec: (config) => config?.withTimeZone ? 'timestamptz' : 'timestamp')
  • Extended list of postgis types for codecs (improvement for #5711)
  • Updated codecs: geometry -> geometry(point), geometry:tuple -> geometry(point):tuple
  • Switched PG transactions from class properties back to class methods (fixes #5709)
  • Updated AWS Data Api codecs, removed query typings, improved input param mapping
  • Removed prepared query typings field from all builders
  • Added column argument to CastParam,CastArrayParam codecs

Migration updates in SQLite

  • Added migration conflict detection for SQLite. When migration history has multiple open branches, drizzle-kit generate now checks whether those branches can be merged safely before creating the next migration. This helps catch cases where two migrations were created from the same parent and then changed the same SQLite object in incompatible ways, for example two branches changing the same table, index, or view.
npx drizzle-kit generate
  • If the conflict is expected and you want to continue anyway, pass --ignore-conflicts to skip the conflict check for that command.
npx drizzle-kit generate --ignore-conflicts
npx drizzle-kit check --ignore-conflicts
  • Added proper SQLite migration tree merging. New snapshots now collect all open leaf snapshot IDs and write them as parents, instead of keeping only one latest parent. This means a new migration generated after branching can merge all open leaves and use the combined SQLite state for the next snapshot diff.
{
  "prevIds": ["first-open-leaf-id", "second-open-leaf-id"]
}
  • Fixed DrizzleQueryError and TransactionRollbackError constructors to properly set the error name for better instanceof checks
  • Fixed error handling in aws-data-api to properly show database error messages

v1.0.0-beta.22

16 Apr 10:24
c98b421

Choose a tag to compare

v1.0.0-beta.22 Pre-release
Pre-release

Bug fixed

1.0.0-beta.21

14 Apr 09:40
498f7d4

Choose a tag to compare

1.0.0-beta.21 Pre-release
Pre-release

More fixes for the drizzle-kit migration process and commutativity checks

  • Adding a value to a PostgreSQL enum will no longer be treated as commutative
  • Enum values added in different leaves will now be merged properly

1.0.0-beta.20

27 Mar 17:17
1a01082

Choose a tag to compare

1.0.0-beta.20 Pre-release
Pre-release
  • 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

Thanks to @EthanKim88, @0x90sh and @wgoodall01 for reaching out to us with a reproduction and suggested fix

0.45.2

27 Mar 17:06
273c780

Choose a tag to compare

  • 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

Thanks to @EthanKim88, @0x90sh and @wgoodall01 for reaching out to us with a reproduction and suggested fix

v1.0.0-beta.19

23 Mar 19:43
01d681d

Choose a tag to compare

v1.0.0-beta.19 Pre-release
Pre-release

New Features

sqlcommenter support for PostgreSQL and MySQL

You can now add custom tags to the query. These tags will be appended to the end of each query, helping the database add metadata/tags to it. This will be especially useful with PlanetScale’s new Database Traffic Control feature

// raw string support
db.select().from().comment("key='val'");
db.select().from().comment("my_first_tag");

// developer friendly dedicated to tags
db.select().from().comment({ key: 'val' });

Example:

db.select().from(comments).comment({ priority: 'high', category: "analytics" });
select "id", "name" from "comments" /*priority='high',category='analytics'*/

The only limitation is that you can't use comments with a prepared statement:

// can't be used
const p = db.select().from().prepare();
// ❌
p.comment({ key: 'val' }).execute();

Bug fixes

Updates

  • Updated migrate() function for mysql dialect to correctly manage multiple databases

  • The behavior for reading schema files has been updated. From now only files with the following extensions will be processed: .js .mjs .cjs .jsx .ts .mts .cts .tsx. All other file types will be ignored

v1.0.0-beta.18

17 Mar 11:20
7eb39f0

Choose a tag to compare

v1.0.0-beta.18 Pre-release
Pre-release

New driver support for kit and studio

You can now use the node:sqlite driver to run migrations and browse Drizzle Studio. If node:sqlite is available at runtime, we will automatically detect it and use it.

Fixes

drizzle-kit@0.31.10

17 Mar 09:31
4aa6ecf

Choose a tag to compare

  • Updated to hanji@0.0.8 - native bun stringWidth, stripANSI support, errors for non-TTY environments
  • We've migrated away from esbuild-register to tsx loader, it will now allow to use drizzle-kit seamlessly with both ESM and CJS modules
  • We've also added native Bun and Deno launch support, which will not trigger tsx loader and utilise native bun and deno imports capabilities and faster startup times

v1.0.0-beta.17

11 Mar 17:26
67b1795

Choose a tag to compare

v1.0.0-beta.17 Pre-release
Pre-release

New SQLite driver node-sqlite

Usage example:

import { drizzle } from 'drizzle-orm/node-sqlite';

const db = drizzle("sqlite.db");

const result = db.select().from(...);

If you need to provide your existing driver:

import { drizzle } from 'drizzle-orm/node-sqlite';
import { DatabaseSync } from 'node:sqlite';

const sqlite = new DatabaseSync('sqlite.db');
const db = drizzle({ client: sqlite });

const result = db.select().from(...);

Fixes

We added a few checks to the migration upgrade logic introduced in beta.16. Now, when your migrations table is upgraded, we double-check that all entities in the table have been updated. If any are missing, we prompt you to pull all migrations into your environment so that we can properly update the drizzle_migrations table