sea-orm
sea-orm copied to clipboard
Distinct support?
I saw sea-query supports it, but It doesn't seem like it's supported yet in sea-orm.
Hey @edg-l, welcome! The DISTINCT syntax is not yet supported in sea-orm. However, I believe you can use GROUP BY to construct similar query.
it's support by sea-query crates @edg-l .
group by does the trick for now, still would be awesome to have distinct supported
@edg-l we add support for some types of DISTINCT into sea-query! PR: https://github.com/SeaQL/sea-query/pull/313
I'll open this issue for contributions. With support of DISTINCT in SeaQuery, we could bring it to SeaORM for sure :)
Hi, I am interested in this issue.
I'd like to work on this issue, so could you tell me a little more about it?
Hey @kyoto7250, thanks for the interest! I have a rough idea for it. Please share your thoughts as well :)
In SeaQuery select statement, there are two methods to construct distinct select:
sea_query::SelectStatement::distinct()sea_query::SelectStatement::distinct_on()
https://github.com/SeaQL/sea-query/blob/563dd26d3a0b20c24fcca8904afb5849aab9de31/src/query/select.rs#L314-L376
We just simply introduce these two methods into sea_orm::QuerySelect. Similar to what we did for the sea_orm::QuerySelect::column() method:
- https://github.com/SeaQL/sea-orm/blob/1385b749cbf6425c62bf2c7cf060d655f1a649dc/src/query/helper.rs#L15-L47
- we should have docs and examples for each method
- also,
sea_orm::QuerySelect::column()docs should state this method is applicable to PostgreSQL only