Releases: drizzle-team/drizzle-orm
0.23.7
0.23.6
- 🐛 Fixed referencing the selected aliased field in the same query
- 🐛 Fixed decimal column data type in MySQL
- 🐛 Fixed mode autocompletion for integer column in SQLite
- 🐛 Fixed extra parentheses in the generated SQL for the
IN
operator (#382) - 🐛 Fixed regression in
pgEnum.enumValues
type (#358) - 🎉 Allowed readonly arrays to be passed to
pgEnum
0.23.5
- 🐛 Various minor bugfixes
0.23.4
- 🐛 Fixed broken types in Kysely and Knex adapters
0.23.3
0.23.2
- 🐛 Rolled back some breaking changes for drizzle-kit
0.23.1
- 🐛 Re-export
InferModel
fromdrizzle-orm
0.23.0
-
🎉 Added Knex and Kysely adapters! They allow you to manage the schemas and migrations with Drizzle and query the data with your favorite query builder. See documentation for more details:
-
🎉 Added "type maps" to all entities. You can access them via the special
_
property. For example:const users = mysqlTable('users', { id: int('id').primaryKey(), name: text('name').notNull(), }); type UserFields = typeof users['_']['columns']; type InsertUser = typeof users['_']['model']['insert'];
Full documentation on the type maps is coming soon.
-
🎉 Added
.$type()
method to all column builders to allow overriding the data type. It also replaces the optional generics on columns.// Before const test = mysqlTable('test', { jsonField: json<Data>('json_field'), }); // After const test = mysqlTable('test', { jsonField: json('json_field').$type<Data>(), });
-
❗ Changed syntax for text-based enum columns:
// Before const test = mysqlTable('test', { role: text<'admin' | 'user'>('role'), }); // After const test = mysqlTable('test', { role: text('role', { enum: ['admin', 'user'] }), });
-
🎉 Allowed passing an array of values into
.insert().values()
directly without spreading:const users = mysqlTable('users', { id: int('id').primaryKey(), name: text('name').notNull(), }); await users.insert().values([ { name: 'John' }, { name: 'Jane' }, ]);
The spread syntax is now deprecated and will be removed in one of the next releases.
-
🎉 Added "table creators" to allow for table name customization:
import { mysqlTableCreator } from 'drizzle-orm/mysql-core'; const mysqlTable = mysqlTableCreator((name) => `myprefix_${name}`); const users = mysqlTable('users', { id: int('id').primaryKey(), name: text('name').notNull(), }); // Users table is a normal table, but its name is `myprefix_users` in runtime
-
🎉 Implemented support for selecting/joining raw SQL expressions:
// select current_date + s.a as dates from generate_series(0,14,7) as s(a); const result = await db .select({ dates: sql`current_date + s.a`, }) .from(sql`generate_series(0,14,7) as s(a)`);
-
🐛 Fixed a lot of bugs from user feedback on GitHub and Discord (thank you! ❤). Fixes #293 #301 #276 #269 #253 #311 #312
0.22.0
-
🎉 Introduced a standalone query builder that can be used without a DB connection:
import { queryBuilder as qb } from 'drizzle-orm/pg-core'; const query = qb.select().from(users).where(eq(users.name, 'Dan')); const { sql, params } = query.toSQL();
-
🎉 Improved
WITH ... SELECT
subquery creation syntax to more resemble SQL:Before:
const regionalSales = db .select({ region: orders.region, totalSales: sql`sum(${orders.amount})`.as<number>('total_sales'), }) .from(orders) .groupBy(orders.region) .prepareWithSubquery('regional_sales'); await db.with(regionalSales).select(...).from(...);
After:
const regionalSales = db .$with('regional_sales') .as( db .select({ region: orders.region, totalSales: sql<number>`sum(${orders.amount})`.as('total_sales'), }) .from(orders) .groupBy(orders.region), ); await db.with(regionalSales).select(...).from(...);
0.21.1
-
🎉 Added support for
HAVING
clause -
🎉 Added support for referencing selected fields in
.where()
,.having()
,.groupBy()
and.orderBy()
using an optional callback:await db .select({ id: citiesTable.id, name: sql<string>`upper(${citiesTable.name})`.as('upper_name'), usersCount: sql<number>`count(${users2Table.id})::int`.as('users_count'), }) .from(citiesTable) .leftJoin(users2Table, eq(users2Table.cityId, citiesTable.id)) .where(({ name }) => sql`length(${name}) >= 3`) .groupBy(citiesTable.id) .having(({ usersCount }) => sql`${usersCount} > 0`) .orderBy(({ name }) => name);