drizzle-team / drizzle-team/drizzle-orm
[BUG]: Incorrect type inference on relational query
- 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.27.2
### What version of `drizzle-kit` are you using?
0.19.12
### Describe the Bug
My prepared statement is correctly returning the data I would expect, but the type that is inferred does not match.
Prepared Statement
```
export const pGetTrainingSetWithExamples = db.query.trainingSets
.findFirst({
where: eq(trainingSets.publicId, placeholder("publicId")),
with: {
examples: true,
},
})
.prepare();
```
Returned data:
```
{
id: 1,
publicId: 'abcd',
userId: '1234',
name: 'Indicators',
description: 'Indicators',
stopSequence: null,
promptSeparator: null,
createdAt: 2023-08-02T06:53:30.000Z,
lastUpdated: 2023-08-02T06:53:30.000Z,
examples: [
{
id: 1,
prompt: "Hi",
completion: 'Hello',
flagged: null,
reviewed: null,
locked: null,
validFrom: null,
validTo: null,
trainingSetId: 1,
createdAt: 2023-08-02T08:05:49.000Z,
lastUpdated: 2023-08-02T08:05:49.000Z
}
]
}
```
I would expect `examples` to be on the type. You can see from the screenshot below that intellisense is not picking up on it.
### Expected behavior
The type to match the data
### Environment & setup
local
Contributor guide
Assessment
This issue has not been assessed yet.