`db.$count` with extras throws error when correlating with outer table
Hi! I'm trying to use
.extras()
with db.query.orderTable.findMany()
to get the count of related orderItemTable
rows like this:
But I get the following error:
It seems like orderTable.id
is not available to the subquery context. I’ve followed the Drizzle docs (like how postsCount is used), but it still fails.
My goal: add an itemCount column using a correlated subquery inside extras.Drizzle ORM - Utils
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
2 Replies
That's a SQL error that indicates that the table/column name you provided doesn't match what's in the database
Check your drizzle schema and compare to your db table definitions
If it matches correctly then there might be a bug
hi @Sillvva , thanks for your precious time, i have reported
GitHub
[BUG]: extras does not qualify outer table columns, leading to inco...
Report hasn't been filed before. I have verified that the bug I'm about to report hasn't been filed before. What version of drizzle-orm are you using? ^0.44.2 What version of drizzle-ki...