© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
ShiftyMcCool

Dynamic where clause

Hello, I'm attempting to following the documentation here https://orm.drizzle.team/docs/dynamic-query-building to build a dynamic query but I'm getting the following error:
Generic type 'PgSelect<TTableName, TSelection, TSelectMode, TNullabilityMap>' requires between 3 and 4 type arguments.
Generic type 'PgSelect<TTableName, TSelection, TSelectMode, TNullabilityMap>' requires between 3 and 4 type arguments.


My code is:
  private filterByProgramLevel<T extends PgSelect>(qb: T, programLevel: ProgramLevel): T {
    return qb.where(and(isNull(lessons.deletedAt), eq(lessons.programLevel, programLevel)))
  }
  private filterByProgramLevel<T extends PgSelect>(qb: T, programLevel: ProgramLevel): T {
    return qb.where(and(isNull(lessons.deletedAt), eq(lessons.programLevel, programLevel)))
  }


Any suggestions? Or, are there any other ways of making dynamic
WHERE
WHERE
clauses? This seems like a bit of a hassle to do a common thing so I'm thinking I don't really need to do it this way 🤷‍♂️
image.png
Dynamic query building - Drizzle ORM
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

Using `$dynamic()` to enhance where clause
Drizzle TeamDTDrizzle Team / help
2y ago
Double 'where' clause in dynamic query overriding the original 'where' clause not combining
Drizzle TeamDTDrizzle Team / help
15mo ago
Missing nested where clause
Drizzle TeamDTDrizzle Team / help
2y ago
[Beginner] complex "where" clause
Drizzle TeamDTDrizzle Team / help
3y ago