Files
drizzle-team--drizzle-orm/changelogs/drizzle-orm/0.20.0.md
T
2026-07-13 12:10:05 +08:00

24 lines
689 B
Markdown

- 🎉 **Implemented support for WITH clause ([docs](/drizzle-orm/src/pg-core/README.md#with-clause)). Example usage:**
```ts
const sq = db
.select()
.from(users)
.prepareWithSubquery('sq');
const result = await db
.with(sq)
.select({
id: sq.id,
name: sq.name,
total: sql<number>`count(${sq.id})::int`(),
})
.from(sq)
.groupBy(sq.id, sq.name);
```
- 🐛 Fixed various bugs with selecting/joining of subqueries.
- ❗ Renamed `.subquery('alias')` to `.as('alias')`.
- ❗ ``sql`query`.as<type>()`` is now ``sql<type>`query`()``. Old syntax is still supported, but is deprecated and will be removed in one of the next releases.