drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Add ability to use CTEs with UNION queries

Open
#2,230 5 comments 5 reactions 0 assignees View on GitHub
enhancement qb/crud qb/cte qb/set-operators
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Describe what you want

When peforming a union, I would like to be able to use the "with" clause to define a CTE. For example:

```ts
const usersSubQuery = db
.$with('sq')
.as(getUserSubsetQuery());

await db.with(usersSubQuery).union(getFriendsWithSpecialDogsQuery,getFriendsWithSpecialCatsQuery);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.