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
24.69k stars 651 forks source link

[BUG]: Incompatible PostgreSQL database union types #3196

Open JakobLierman opened 1 month ago

JakobLierman commented 1 month ago

What version of drizzle-orm are you using?

0.35.3

What version of drizzle-kit are you using?

No response

Describe the Bug

My goal is to support both the node-postgres and neon-http drivers. My db object is therefore defined as a union type of the two drivers.

This gives a Typescript error when using the partial insert returning (https://orm.drizzle.team/docs/insert#insert-returning). All of a sudden, it's not expecting a parameter, even though it's supported by both drivers (they're both PostgreSQL).

Small repo to reproduce the issue: https://github.com/JakobLierman/drizzle-union-type-bug.

Expected behavior

No Typescript errors should occur on functionality supported by both database types.

Environment & setup

Both on Webstorm and Visual Studio Code, not that it matters all that much. You can also test it out bare bones by running npm run check-types (tsc --noEmit) and see where it fails.

JakobLierman commented 4 weeks ago

For anyone trying the same. I've changed my driver from Neon HTTP to the Neon serverless one (using WebSockets). Works perfectly now.