Expand description
Final SQL statement assembly.
Wraps the SQL produced by super::builder into CTE-based final statements
that return a uniform response shape: total count, page count, body,
response headers, and response status. This module sits at the top of the
SQL generation pipeline, right before the query is handed to the executor.
§Pipeline
builder.rs (SELECT / INSERT / CALL …) ──▶ statements.rs (CTE wrapper) ──▶ executor§SQL Example
WITH dbrst_source AS (
SELECT "public"."users"."id" AS "id", "public"."users"."name" AS "name"
FROM "public"."users"
)
SELECT
NULL AS total_result_set,
pg_catalog.count(_dbrst_t) AS page_total,
coalesce(json_agg(_dbrst_t), '[]')::text AS body,
nullif(current_setting('response.headers', true), '') AS response_headers,
nullif(current_setting('response.status', true), '') AS response_status
FROM (SELECT * FROM dbrst_source) AS _dbrst_tFunctions§
- main_
call - Build the final function call statement with CTE wrapper.
- main_
read - Build the final read statement with CTE wrapper.
- main_
write - Build the final mutation statement with CTE wrapper.
- main_
write_ split - Build split mutation + aggregation statements for backends without DML-in-CTE support.