drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
21.47k stars 486 forks source link

[FEATURE]: Multiple union / unionAll #2490

Open Farnsi opened 2 weeks ago

Farnsi commented 2 weeks ago

Describe what you want

Currently only 2 queries are corretly combined to a union.

When you add a third query, the first two are wrapped with () and all wrapped too, that doesn't work.

Example (current result of drizzle), when unionAll(query1, query2, query3)

(
  (
    SELECT ...
  )
  UNION ALL
  (
    SELECT ...
  )
)
UNION ALL
(
  SELECT ...
)