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.57k stars 490 forks source link

[BUG]: Relation Query type merges when using the same "with" key #2343

Open khuezy opened 1 month ago

khuezy commented 1 month ago

What version of drizzle-orm are you using?

0.30.10

What version of drizzle-kit are you using?

0.21.13

Describe the Bug

schema:

author: text('id') // a reference to the author id

relation:

author: one(author, {... // notice the same key as the schema "author"

query:

with: {
   author: true // The "author" should be the data from the author table, and not the "id" reference
}

This results is type: author: (string & {what ever type the relation query is})

Expected behavior

When using with: sameKeyAsSchema, the types shouldn't merge. It should use the types from the with relation.

Environment & setup

No response