Description
Background
#1733 introduced some utilities to build CTEs:
nexus/src/db/subquery.rs
- Adds the definition of traits like Subquery
, as well as a CteBuilder
to help building arbitrary CTEs.
nexus/db-macros/src/lib.rs
- Adds macro to derive Subquery
(identifying that a query can be used in a CTE arm)
nexus/db-macros/src/subquery.rs
- Implementation of Subquery
macro
nexus/src/db/alias.rs
- Defines expression which allows field aliasing (FOO as BAR
in SELECT/RETURNING queries)
nexus/db-model/src/queries
- Uses the table!
macro to describe the columns of subqueries. This generates more code than we actually want!
Goal
It would be nice to simplify the "known hacky" pieces of this -- e.g. re-using the table!
macro for subqueries -- and to upstream this support into Diesel, to ensure that we don't get broken by future Diesel revisions.