Selecto.Builder.CteSql (Selecto v0.3.8)
SQL generation for PostgreSQL Common Table Expressions (CTEs).
Generates SQL for both non-recursive and recursive WITH clauses, handling dependency ordering, column specifications, and proper PostgreSQL CTE syntax.
Link to this section Summary
Functions
Build a single CTE definition SQL.
Build WITH clause SQL from a list of CTE specifications.
Create a CTE reference that can be used in joins and queries.
Integrate CTEs with a main query, combining the WITH clause with the query.
Link to this section Functions
build_cte_definition(spec)
Build a single CTE definition SQL.
Returns {cte_definition_iodata, parameters} for a single CTE.
build_with_clause(ctes)
Build WITH clause SQL from a list of CTE specifications.
Returns {with_clause_iodata, parameters} tuple with properly ordered CTEs and parameter bindings.
create_cte_reference(cte_name)
Create a CTE reference that can be used in joins and queries.
Returns a structure that represents the CTE as a queryable table.
integrate_ctes_with_query(ctes, query_iodata, query_params)
Integrate CTEs with a main query, combining the WITH clause with the query.
Returns the complete SQL with CTEs at the top.