Releases: drizzle-team/drizzle-orm
0.42.0
Features
Duplicate imports removal
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.
enum Test {
a = 'a',
b = 'b',
c = 'c',
}
const tableWithTsEnums = mysqlTable('enums_test_case', {
id: serial().primaryKey(),
enum1: mysqlEnum(Test).notNull(),
enum2: mysqlEnum(Test).default(Test.a),
});
await db.insert(tableWithTsEnums).values([
{ id: 1, enum1: Test.a, enum2: Test.b, enum3: Test.c },
{ id: 2, enum1: Test.a, enum3: Test.c },
{ id: 3, enum1: Test.a },
]);
const res = await db.select().from(tableWithTsEnums);
expect(res).toEqual([
{ id: 1, enum1: 'a', enum2: 'b', enum3: 'c' },
{ id: 2, enum1: 'a', enum2: 'a', enum3: 'c' },
{ id: 3, enum1: 'a', enum2: 'a', enum3: 'b' },
]);Improvements
- Make
inArrayacceptReadonlyArrayas a value - thanks @Zamiell - Pass row type parameter to
@planetscale/database's execute - thanks @ayrton - New
InferEnumtype - thanks @totigm
Issues closed
[email protected]
Features and improvements
Enum DDL improvements
For situations where you drop an enum value or reorder values in an enum, there is no native way to do this in PostgreSQL. To handle these cases, drizzle-kit used to:
- Change the column data types from the enum to text
- Drop the old enum
- Add the new enum
- Change the column data types back to the new enum
However, there were a few scenarios that weren’t covered: PostgreSQL wasn’t updating default expressions for columns when their data types changed
Therefore, for cases where you either change a column’s data type from an enum to some other type, drop an enum value, or reorder enum values, we now do the following:
- Change the column data types from the enum to text
- Set the default using the ::text expression
- Drop the old enum
- Add the new enum
- Change the column data types back to the new enum
- Set the default using the ::<new_enum> expression
esbuild version upgrade
For drizzle-kit we upgraded the version to latest (0.25.2), thanks @paulmarsicloud
Bug fixes
[email protected]
0.41.0
bigint,numbermodes forSQLite,MySQL,PostgreSQL,SingleStoredecimal&numericcolumn types- Changed behavior of
sql-jsquery preparation to query prebuild instead of db-side prepare due to need to manually free prepared queries, removed.free()method - Fixed
MySQL,SingleStorevarcharallowing not specifyinglengthin config - Fixed
MySQL,SingleStorebinary,varbinarydata\type mismatches - Fixed
numeric\decimaldata\type mismatches: #1290, #1453 - Fixed
drizzle-studio+AWS Data Apiconnection issue: #3224 - Fixed
isConfigutility function checking types of wrong fields - Enabled
supportBigNumbersin auto-createdmysql2driver instances - Fixed custom schema tables querying in RQBv1: #4060
- Removed in-driver mapping for postgres types
1231(numeric[]),1115(timestamp[]),1185(timestamp_with_timezone[]),1187(interval[]),1182(date[]), preventing precision loss and data\type mismatches - Fixed
SQLitebuffer-modeblobsometimes returningnumber[]
0.40.1
Updates to neon-http for @neondatabase/[email protected] - thanks @jawj
Starting from this version, drizzle-orm will be compatible with both @neondatabase/serverless <1.0 and >1.0
0.40.0
New Features
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
gelCLI to manage your schema. - Use the
gelCLI 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";
const gelClient = createClient();
const db = drizzle({ client: gelClient });
const result = await db.execute('select 1');and drizzle-gel schema definition
import { gelTable, uniqueIndex, uuid, smallint, text } from "drizzle-orm/gel-core"
import { sql } from "drizzle-orm"
export const users = gelTable("users", {
id: uuid().default(sql`uuid_generate_v4()`).primaryKey(),
age: smallint(),
email: text().notNull(),
name: text(),
});On the drizzle-kit side you can now use dialect: "gel"
// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
dialect: 'gel',
});For a complete Get Started tutorial you can use our new guides:
[email protected]
New Features
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
gelCLI to manage your schema. - Use the
gelCLI 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.
On the drizzle-kit side you can now use dialect: "gel"
// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
dialect: 'gel',
});For a complete Get Started tutorial you can use our new guides:
0.39.3
- Remove
reactfrom peerDependencies
0.39.2
- To be compatible with latest Neon Auth feature we renamed the pre-defined schema internally, from
neon_identitytoneon_auth- thanks @pffigueiredo