drizzle-team / drizzle-team/drizzle-orm

[BUG]: Nested object in select query

Open
#2,050 27 comments 20 reactions 0 assignees View on GitHub
improvement qb/crud
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.29.3

### What version of `drizzle-kit` are you using?

0.20.14

### Describe the Bug

My code is

``` javascript
const feedbacks = await drizzleClient
.select({
...getTableColumns(feedbackFirst),
project: {
...getTableColumns(project),
},
userFrom: {
...getTableColumns(users),
userAbout: {
...getTableColumns(userAbout),
avatar: {
...getTableColumns(avatars),
photo: {
...getTableColumns(photos),
}
}
}
}
})
.from(feedbackFirst)
.innerJoin(project, eq(project.prid, feedbackFirst.prid))
.innerJoin(users, eq(users.uid, feedbackFirst.uidFrom))
.innerJoin(userAbout, eq(userAbout.uid, users.uid))
.innerJoin(avatars, eq(avatars.uid, users.uid))
.innerJoin(photos, eq(photos.phid, avatars.phid))
```

There is an error near ```avatar```

```
Object literal may only specify known properties, and avatar does not exist in type
```
Снимок экрана 2024-03-20 в 16 33 18

Despite of the type error, the query result is correct, with all nesting. How to fix the type error? And is it possible?

### Expected behavior

The result has the correct types

### Environment & setup

webstorm 2023.3.5
ts 5
node 21.4.0
macos sonoma 14.4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.