tomjaguarpaw / haskell-opaleye

Other
599 stars 115 forks source link

distinctOn an empty set of columns should be `limit 1`, not a no-op #518

Closed duairc closed 2 years ago

duairc commented 2 years ago

I understand why this is made a no-op, because an empty list of columns in a DISTINCT ON query is not syntactically valid in SQL. However, our Haskell types don't forbid it. So the question is, semantically, what does this mean? And I think it has to be an unconditional limit 1.

tomjaguarpaw commented 2 years ago

Oh yes, I think you're right! It will require a new major release. How awkward. Maybe that will prompt me to finally finish the Column -> Field migration.

tomjaguarpaw commented 2 years ago

Would you like to add this as a new function distinctOnByCorrect? Then at least it will be in Opaleye and rel8 can use it without having to implement its own version. Then in version 8 I will replace distinctOnBy with it and deprecate distinctOnByCorrect.

(I'll get round to this sometime in the near future unless you do.)

duairc commented 2 years ago

Sure. I just force-pushed that change.

tomjaguarpaw commented 2 years ago

I've implemented this and will do a release at some point in the near future.

tomjaguarpaw commented 2 years ago

Released as https://hackage.haskell.org/package/opaleye-0.7.4.0