alloc / tusken

100% type-safe query builder compatible with any Postgres client 🐘 Generated table/function types, tree-shakable, implicit type casts, and more
Other
223 stars 3 forks source link

Warn when aggregate function is used alongside non-aggregate selection #4

Open aleclarson opened 2 years ago

aleclarson commented 2 years ago

If an aggregate function is used within a db.select call, you need GROUP BY to include non-aggregate selections.

Current progress

aleclarson commented 2 years ago

We'll probably add a groupBy helper function for use in the selector function.

db.select(t.user(user => [
  groupBy(user.id),
  pg.avg(user.followerCount),
]))