drizzle-team/drizzle-orm (drizzle-orm)
### [`v0.28.6`](https://togithub.com/drizzle-team/drizzle-orm/releases/tag/0.28.6)
[Compare Source](https://togithub.com/drizzle-team/drizzle-orm/compare/0.28.5...0.28.6)
#### Changes
> **Note**:
> MySQL `datetime` with `mode: 'date'` will now store dates in UTC strings and retrieve data in UTC as well to align with MySQL behavior for `datetime`. If you need a different behavior and want to handle `datetime` mapping in a different way, please use `mode: 'string'` or [Custom Types](https://orm.drizzle.team/docs/custom-types) implementation
Check [Fix Datetime mapping for MySQL](https://togithub.com/drizzle-team/drizzle-orm/pull/1082) for implementation details
#### New Features
##### π `LibSQL` batch api support
Reference: https://docs.turso.tech/reference/client-access/javascript-typescript-sdk#execute-a-batch-of-statements
Batch API usage example:
```ts
const batchResponse = await db.batch([
db.insert(usersTable).values({ id: 1, name: 'John' }).returning({
id: usersTable.id,
}),
db.update(usersTable).set({ name: 'Dan' }).where(eq(usersTable.id, 1)),
db.query.usersTable.findMany({}),
db.select().from(usersTable).where(eq(usersTable.id, 1)),
db.select({ id: usersTable.id, invitedBy: usersTable.invitedBy }).from(
usersTable,
),
]);
```
Type for `batchResponse` in this example would be:
```ts
type BatchResponse = [
{
id: number;
}[],
ResultSet,
{
id: number;
name: string;
verified: number;
invitedBy: number | null;
}[],
{
id: number;
name: string;
verified: number;
invitedBy: number | null;
}[],
{
id: number;
invitedBy: number | null;
}[],
];
```
All possible builders that can be used inside `db.batch`:
```ts
`db.all()`,
`db.get()`,
`db.values()`,
`db.run()`,
`db.query.
.findMany()`,
`db.query.
.findFirst()`,
`db.select()...`,
`db.update()...`,
`db.delete()...`,
`db.insert()...`,
```
More usage examples here: [integration-tests/tests/libsql-batch.test.ts](https://togithub.com/drizzle-team/drizzle-orm/pull/1161/files#diff-17253895532e520545027dd48dcdbac2d69a5a49d594974e6d55d7502f89b838R248) and in [docs](https://orm.drizzle.team/docs/batch-api)
##### π Add json mode for text in SQLite
Example
```ts
const test = sqliteTable('test', {
dataTyped: text('data_typed', { mode: 'json' }).$type<{ a: 1 }>().notNull(),
});
```
##### π Add `.toSQL()` to Relational Query API calls
Example
```ts
const query = db.query.usersTable.findFirst().toSQL();
```
##### π Added new PostgreSQL operators for Arrays - thanks [@L-Mario564](https://togithub.com/L-Mario564)
List of operators and usage examples
`arrayContains`, `arrayContained`, `arrayOverlaps`
```ts
const contains = await db.select({ id: posts.id }).from(posts)
.where(arrayContains(posts.tags, ['Typescript', 'ORM']));
const contained = await db.select({ id: posts.id }).from(posts)
.where(arrayContained(posts.tags, ['Typescript', 'ORM']));
const overlaps = await db.select({ id: posts.id }).from(posts)
.where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']));
const withSubQuery = await db.select({ id: posts.id }).from(posts)
.where(arrayContains(
posts.tags,
db.select({ tags: posts.tags }).from(posts).where(eq(posts.id, 1)),
));
```
##### π Add more SQL operators for where filter function in Relational Queries - thanks [@cayter](https://togithub.com/cayter)!
**Before**
```ts
import { inArray } from "drizzle-orm/pg-core";
await db.users.findFirst({
where: (table, _) => inArray(table.id, [ ... ])
})
```
**After**
```ts
await db.users.findFirst({
where: (table, { inArray }) => inArray(table.id, [ ... ])
})
```
#### Bug Fixes
- π [Correct where in on conflict in sqlite](https://togithub.com/drizzle-team/drizzle-orm/pull/1076) - Thanks [@hanssonduck](https://togithub.com/hanssonduck)!
- π [Fix libsql/client type import](https://togithub.com/drizzle-team/drizzle-orm/pull/1122) - Thanks [@luisfvieirasilva](https://togithub.com/luisfvieirasilva)!
- π [Fix: raw sql query not being mapped properly on RDS](https://togithub.com/drizzle-team/drizzle-orm/pull/1071) - Thanks [@boian-ivanov](https://togithub.com/boian-ivanov)
- π [Fix Datetime mapping for MySQL](https://togithub.com/drizzle-team/drizzle-orm/pull/1082) - thanks [@Angelelz](https://togithub.com/Angelelz)
- π [Fix smallserial generating as serial](https://togithub.com/drizzle-team/drizzle-orm/pull/1127) - thanks [@L-Mario564](https://togithub.com/L-Mario564)
Configuration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, 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
This PR has been generated by Mend Renovate. View repository job log here.
CI is running/has finished running commands for commit 1b16908b65a14fdbab7548fcb3134fa483d8614d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
This PR contains the following updates:
^0.28.5
->^0.28.6
Release Notes
drizzle-team/drizzle-orm (drizzle-orm)
### [`v0.28.6`](https://togithub.com/drizzle-team/drizzle-orm/releases/tag/0.28.6) [Compare Source](https://togithub.com/drizzle-team/drizzle-orm/compare/0.28.5...0.28.6) #### Changes > **Note**: > MySQL `datetime` with `mode: 'date'` will now store dates in UTC strings and retrieve data in UTC as well to align with MySQL behavior for `datetime`. If you need a different behavior and want to handle `datetime` mapping in a different way, please use `mode: 'string'` or [Custom Types](https://orm.drizzle.team/docs/custom-types) implementation Check [Fix Datetime mapping for MySQL](https://togithub.com/drizzle-team/drizzle-orm/pull/1082) for implementation details #### New Features ##### π `LibSQL` batch api support Reference: https://docs.turso.tech/reference/client-access/javascript-typescript-sdk#execute-a-batch-of-statements Batch API usage example: ```ts const batchResponse = await db.batch([ db.insert(usersTable).values({ id: 1, name: 'John' }).returning({ id: usersTable.id, }), db.update(usersTable).set({ name: 'Dan' }).where(eq(usersTable.id, 1)), db.query.usersTable.findMany({}), db.select().from(usersTable).where(eq(usersTable.id, 1)), db.select({ id: usersTable.id, invitedBy: usersTable.invitedBy }).from( usersTable, ), ]); ``` Type for `batchResponse` in this example would be: ```ts type BatchResponse = [ { id: number; }[], ResultSet, { id: number; name: string; verified: number; invitedBy: number | null; }[], { id: number; name: string; verified: number; invitedBy: number | null; }[], { id: number; invitedBy: number | null; }[], ]; ``` All possible builders that can be used inside `db.batch`: ```ts `db.all()`, `db.get()`, `db.values()`, `db.run()`, `db.query.Configuration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.
The latest updates on your projects. Learn more about Vercel for Git βοΈ
βοΈ Nx Cloud Report
CI is running/has finished running commands for commit 1b16908b65a14fdbab7548fcb3134fa483d8614d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
π See all runs for this branch
β Successfully ran 5 targets
- [`nx affected -t build --parallel=3`](https://cloud.nx.app/runs/6otN9ZHvia) - [`nx affected -t lint --parallel=3`](https://cloud.nx.app/runs/ZtWRgGwf1c) - [`nx affected -t typecheck --parallel=3`](https://cloud.nx.app/runs/BOQCry5jm5) - [`nx-cloud record -- pnpm format:check`](https://cloud.nx.app/runs/6eWpkaT3Sv) - [`nx build @noodle/web`](https://cloud.nx.app/runs/vAUU6m2Rp3)Sent with π from NxCloud.