Skip to content

Commit 388a474

Browse files
committed
Merge branch 'main' of https://github.com/drizzle-team/drizzle-orm into beta
2 parents c0277c0 + 8b8d78e commit 388a474

312 files changed

Lines changed: 8434 additions & 28458 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-feature-branch.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ jobs:
237237

238238
- uses: actions/setup-node@v4
239239
with:
240-
node-version: '18.18'
240+
node-version: '22'
241241
registry-url: 'https://registry.npmjs.org'
242242

243243
- uses: pnpm/action-setup@v3
@@ -334,7 +334,7 @@ jobs:
334334

335335
- uses: actions/setup-node@v4
336336
with:
337-
node-version: '18.18'
337+
node-version: '22'
338338
registry-url: 'https://registry.npmjs.org'
339339

340340
- uses: pnpm/action-setup@v3
@@ -415,4 +415,4 @@ jobs:
415415
working-directory: ${{ matrix.package }}
416416
shell: bash
417417
env:
418-
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
418+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

.github/workflows/release-latest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ jobs:
360360

361361
- uses: actions/setup-node@v4
362362
with:
363-
node-version: '18.18'
363+
node-version: '22'
364364
registry-url: 'https://registry.npmjs.org'
365365

366366
- uses: pnpm/action-setup@v3

.github/workflows/unpublish-release-feature-branch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- uses: actions/setup-node@v4
2323
with:
24-
node-version: '18.18'
24+
node-version: '22'
2525
registry-url: 'https://registry.npmjs.org'
2626

2727
- name: Unpublish

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.18
1+
22
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- TS language server performance improvements
2+
- Fixed [Buffer is not defined using drizzle-arktype client side with vite](https://github.com/drizzle-team/drizzle-orm/issues/4383)
3+
- Fixed [[BUG]: drizzle-arktype Buffer is undefined](https://github.com/drizzle-team/drizzle-orm/issues/4371)

changelogs/drizzle-kit/0.31.1.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Fixed `drizzle-kit pull` bugs when using Gel extensions.
2+
3+
Because Gel extensions create schema names containing `::` (for example, `ext::auth`), Drizzle previously handled these names incorrectly. Starting with this release, you can use Gel extensions without any problems. Here’s what you should do:
4+
5+
1. Enable extensions schemas in `drizzle.config.ts`
6+
7+
```ts
8+
import { defineConfig } from "drizzle-kit";
9+
10+
export default defineConfig({
11+
dialect: 'gel',
12+
schemaFilter: ['ext::auth', 'public']
13+
});
14+
```
15+
16+
2. Run `drizzle-kit pull`
17+
18+
3. Done!

changelogs/drizzle-kit/0.31.2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Bug fixes
2+
3+
- Fixed relations extraction to not interfere with Drizzle Studio.

changelogs/drizzle-kit/0.31.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Internal changes to Studio context. Added `databaseName` and `packageName` properties for Studio

changelogs/drizzle-kit/0.31.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed `halfvec`, `bit` and `sparsevec` type generation bug in drizzle-kit

changelogs/drizzle-orm/0.44.0.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## Error handling
2+
3+
Starting from this version, we’ve introduced a new `DrizzleQueryError` that wraps all errors from database drivers and provides a set of useful information:
4+
5+
1. A proper stack trace to identify which exact `Drizzle` query failed
6+
2. The generated SQL string and its parameters
7+
3. The original stack trace from the driver that caused the DrizzleQueryError
8+
9+
## Drizzle `cache` module
10+
11+
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.
12+
13+
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.
14+
15+
Out first native integration was built together with Upstash team and let you natively use `upstash` as a cache for your drizzle queries
16+
17+
```ts
18+
import { upstashCache } from "drizzle-orm/cache/upstash";
19+
import { drizzle } from "drizzle-orm/...";
20+
21+
const db = drizzle(process.env.DB_URL!, {
22+
cache: upstashCache({
23+
// 👇 Redis credentials (optional — can also be pulled from env vars)
24+
url: '<UPSTASH_URL>',
25+
token: '<UPSTASH_TOKEN>',
26+
// 👇 Enable caching for all queries by default (optional)
27+
global: true,
28+
// 👇 Default cache behavior (optional)
29+
config: { ex: 60 }
30+
})
31+
});
32+
```
33+
34+
You can also implement your own cache, as Drizzle exposes all the necessary APIs, such as get, put, mutate, etc.
35+
You can find full implementation details on the [website](https://orm.drizzle.team/docs/cache#custom-cache)
36+
37+
```ts
38+
import Keyv from "keyv";
39+
export class TestGlobalCache extends Cache {
40+
private globalTtl: number = 1000;
41+
// This object will be used to store which query keys were used
42+
// for a specific table, so we can later use it for invalidation.
43+
private usedTablesPerKey: Record<string, string[]> = {};
44+
constructor(private kv: Keyv = new Keyv()) {
45+
super();
46+
}
47+
// For the strategy, we have two options:
48+
// - 'explicit': The cache is used only when .$withCache() is added to a query.
49+
// - 'all': All queries are cached globally.
50+
// The default behavior is 'explicit'.
51+
override strategy(): "explicit" | "all" {
52+
return "all";
53+
}
54+
// This function accepts query and parameters that cached into key param,
55+
// allowing you to retrieve response values for this query from the cache.
56+
override async get(key: string): Promise<any[] | undefined> {
57+
...
58+
}
59+
// This function accepts several options to define how cached data will be stored:
60+
// - 'key': A hashed query and parameters.
61+
// - 'response': An array of values returned by Drizzle from the database.
62+
// - 'tables': An array of tables involved in the select queries. This information is needed for cache invalidation.
63+
//
64+
// For example, if a query uses the "users" and "posts" tables, you can store this information. Later, when the app executes
65+
// any mutation statements on these tables, you can remove the corresponding key from the cache.
66+
// If you're okay with eventual consistency for your queries, you can skip this option.
67+
override async put(
68+
key: string,
69+
response: any,
70+
tables: string[],
71+
config?: CacheConfig,
72+
): Promise<void> {
73+
...
74+
}
75+
// This function is called when insert, update, or delete statements are executed.
76+
// You can either skip this step or invalidate queries that used the affected tables.
77+
//
78+
// The function receives an object with two keys:
79+
// - 'tags': Used for queries labeled with a specific tag, allowing you to invalidate by that tag.
80+
// - 'tables': The actual tables affected by the insert, update, or delete statements,
81+
// helping you track which tables have changed since the last cache update.
82+
override async onMutate(params: {
83+
tags: string | string[];
84+
tables: string | string[] | Table<any> | Table<any>[];
85+
}): Promise<void> {
86+
...
87+
}
88+
}
89+
```
90+
91+
For more usage example you can check our [docs](https://orm.drizzle.team/docs/cache#cache-usage-examples)

0 commit comments

Comments
 (0)