SeaQL / sea-query

🔱 A dynamic SQL query builder for MySQL, Postgres and SQLite
https://www.sea-ql.org
Other
1.18k stars 195 forks source link

Unify SelectStatement and WithQuery #813

Open bouk opened 2 months ago

bouk commented 2 months ago

Motivation

WithQuery is currently a separate entity from SelectStatement which is unfortunate, because it restricts where you can use it, i.e. I'd like to use a WithQuery as a FROM with from_subquery in another query but I don't believe I can, because only SelectStatements are accepted.

https://github.com/SeaQL/sea-query/blob/53fd4e902910cf3db9f4332f1c1d1b6b6b3e49a6/src/query/select.rs#L1024

Proposed Solutions

Move with_clause into SelectStatement/UpdateStatement/DeleteStatement/InsertStatement instead of having a separate code path for it.

Additional Information