drizzle-team / drizzle-team/drizzle-orm
[BUG]: Nested partial select type is not recursive
- 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
### Describe the Bug
Not 100% sure if this is a bug or a feature request but the following query works and produces the desired result
```typescript
const result = await db
.select({
id: table.id,
levelOne: {
id: levelOne.id,
levelTwo: {
id: levelTwo.id,
}
},
})
.from(table)
.leftJoin(
levelOne,
eq(levelOne.tableId, table.id),
)
.leftJoin(
levelTwo,
eq(levelTwo.levelOneId, levelOne.id),
);
```
but the types give the following error
```
Type '{ id: PgInteger<{ tableName: "levelTwo"; name: string; data: number; driverParam: string | number; hasDefault: false; notNull: false; }>; levelOneId: PgInteger<...>; }' is not assignable to type 'AnyPgColumn<{}> | SQL | Aliased'.
Type '{ id: PgInteger<{ tableName: "levelTwo"; name: string; data: number; driverParam: string | number; hasDefault: false; notNull: false; }>; levelOneId: PgInteger<...>; }' is missing the following properties from type 'PgColumn, {}, {}>': table, _, primary, notNull, and 9 more.
```
### Expected behavior
No typescript error and correct return type inference.
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.