© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•9mo ago•
7 replies
Raz

Bug: Count in Extras (Relational)

Trying to use the example from: https://orm.drizzle.team/docs/query-utils#count

const results = await context.db.query.label.findMany({
        extras: {
          postsCount: context.db.$count(danceLabel, eq(danceLabel.labelId, label.id)).as("postsCount"),
        },

        limit: input.limit,
        offset: input.offset,
      });
      return results;
const results = await context.db.query.label.findMany({
        extras: {
          postsCount: context.db.$count(danceLabel, eq(danceLabel.labelId, label.id)).as("postsCount"),
        },

        limit: input.limit,
        offset: input.offset,
      });
      return results;



NeonDbError: column "danceId" does not exist
NeonDbError: column "danceId" does not exist


it seems like the output SQL query is WRONG -- it is attempting to match on
label.danceId
label.danceId
instead of
label.id
label.id
Drizzle ORM - Utils
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
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

Count in relational queries
Drizzle TeamDTDrizzle Team / help
3y ago
Optional/Default value for Relational `Extras`
Drizzle TeamDTDrizzle Team / help
3y ago
Best way to get count in extras
Drizzle TeamDTDrizzle Team / help
2y ago
Relational query `extras` are not properly adding sql
Drizzle TeamDTDrizzle Team / help
3y ago