© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago•
7 replies
sixfalls

Unable to query a table with another many to many relation

This seems to be an issue with the type handling, but it also could be an oversight on my part. I have 3 tables, let's call them A, B, and C. A and B have a one to many relation, and B and C also has another one to many relation. I have references to A from B, and references to B from C, but none from A to C. I'm trying to query B using
db.query.B.findFirst({with: {C: true})
db.query.B.findFirst({with: {C: true})
, so I can get the C records of B. The inferred type of
with
with
ends up becoming
{}
{}
, and as a result the response of that doesn't have the types for the relation. On the other hand, if I delete the relations between A and B from my drizzle schema file, the query works fine. What gives?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

many to many relation to same table with one relation field
Drizzle TeamDTDrizzle Team / help
16mo ago
Many-to-many relational query issues
Drizzle TeamDTDrizzle Team / help
3y ago
table with multiple possible one-to-many relation, but not many-to-many
Drizzle TeamDTDrizzle Team / help
2y ago
Many to Many Query With
Drizzle TeamDTDrizzle Team / help
17mo ago