-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Replies: 1 comment · 2 replies
-
This is essentially a duplicate of #3020 That written: I would accept a PR for this, as long as it includes tests + compile tests. For me personally this is not a priority issue, so I likely won't work on this in the next time. |
Beta Was this translation helpful? Give feedback.
All reactions
-
I would like to try to help here with this evolution. |
Beta Was this translation helpful? Give feedback.
All reactions
-
I did not investigate in depth yet what's required to enable the presented usecase. That remains an open question and that's likely the main work that is required here. If someone is willing to do that work that would be great. Otherwise this is a pretty well contained thing in diesels code. To solve it you likely require a good understanding of how traits work in rust and how to write generic impls. From a short look at the code I can say that these ( diesel/diesel/src/pg/query_builder/distinct_on.rs Lines 18 to 52 in fa33e38
diesel/diesel_tests/tests/distinct.rs Lines 1 to 100 in fa33e38
diesel/diesel_compile_tests/tests/fail/distinct_on_requires_matching_order_clause.rs Lines 1 to 90 in fa33e38
|
Beta Was this translation helpful? Give feedback.
-
Let's take a pretty basic SQL example to query latest objects from table
tab
by date with a distinct on two columns:Which is easily translated into this code using the Diesel ORM:
But yet, only single value (i.e. one column) are supported as
distinct_on()
param. It would be great to support multiple columns indistinct_on()
.In this simple example, it isn't a big deal because you could simply write the SQL query. But for big queries, you could use these to filter out results in a same request. Another workaround is to create a view of the first SQL select, then create a table for this view using this trick, but the amount of work required is high for such a simple request.
Beta Was this translation helpful? Give feedback.
All reactions