haskell-beam / beam

A type-safe, non-TH Haskell SQL library and ORM
https://haskell-beam.github.io/beam/
577 stars 170 forks source link

Possible to use aggregates over nullable columns? #86

Open 3noch opened 6 years ago

3noch commented 6 years ago

Is it possible to use aggregates directly over nullable columns? Of course one can manage by filtering and coalescing, but this seems like an unnecessary complication. In particular, it's easy to get avg_ wrong when you coalesce first because each row will still count toward the average. Other aggregates like sum_ don't have this danger.

tathougies commented 6 years ago

This is a good point, and one that I will have to think about more. I hadn't considered the difference with avg_ before.