Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd compiler error for DISTINCT ON that doesn't match initial ORDER BY expressions #1641
Comments
connec
changed the title from
Compiler error for DISTINCT ON that doesn't match initial ORDER BY expressions
to
Add compiler error for DISTINCT ON that doesn't match initial ORDER BY expressions
Apr 14, 2018
This comment has been minimized.
|
I'm not sure that it's possible for us to encode this (without a breaking change), but we definitely should be |
sgrif
added
the
bug
label
Apr 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
connec commentedApr 14, 2018
For example:
This compiles fine, but inevitably causes "SELECT DISTINCT ON expressions must match initial ORDER BY expressions" when executed.
The correct version, of course, is:
entries .order_by((name, date.desc())) .distinct_on(name) .load(&conn)According to the PostgreSQL docs
DISTINCT ONis valid with no ordering, or with a matching prefix. I don't know enough about Rust to have any idea how feasible it is to encode that in the types, but it would be a neat sanity check!Checklist