drizzle-team / drizzle-team/drizzle-orm
[BUG]: Relation Query type merges when using the same "with" key
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### 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_
Contributor guide
Research direction
Reproduce the relation query from the issue with drizzle-orm 0.30.10, using a schema key and relation with the same name. Trace the generated TypeScript result type for the `with` relation; done when the relation value no longer intersects with the schema reference type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100