Nested object in select query?

Drizzle-orm 0.29.3. My code is
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))
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
avatar

Object literal may only specify known properties, and avatar does not exist in type
Object literal may only specify known properties, and avatar does not exist in type
Despite of the type error, the query result is correct, with all nesting. How to fix the type error? And is it possible?
No description
10 Replies
francis
francis10mo ago
is there a chance that your nested object names are colliding with one of the columns returned from getTableColumns such that it's causing a type conflict?
andreas_444
andreas_444OP10mo ago
I doubt, this could have anything to do with column conflicts
No description
andreas_444
andreas_444OP10mo ago
@francis do you have any issues with nested objects?
francis
francis10mo ago
I don't use them. but you're right. I dunno what is happening here
andreas_444
andreas_444OP10mo ago
Another clarification. The only first-level nested object has no type issues
BanJoe
BanJoe8mo ago
@andreas_444 did you ever find a solution to this?
andreas_444
andreas_444OP8mo ago
still no
andreas_444
andreas_444OP8mo ago
GitHub
[BUG]: Nested object in select query · Issue #2050 · drizzle-team/d...
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 const feedbacks = await drizzleClient .select({ ...getTableColumns(f...
rphlmr ⚡
rphlmr ⚡8mo ago
I have an example here: https://gist.github.com/rphlmr/de869cf24816d02068c3dd089b45ae82 Maybe not up to date. An other gist here with community contributions : https://gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15
Gist
Drizzle ORM, deep sub queries
Drizzle ORM, deep sub queries. GitHub Gist: instantly share code, notes, and snippets.
Gist
Drizzle snippets
Drizzle snippets. GitHub Gist: instantly share code, notes, and snippets.
rphlmr ⚡
rphlmr ⚡8mo ago
Look at jsonAggBuildObject
Want results from more Discord servers?
Add your server