Module query
Expand description
query IR — the declarative, parameterized custom-SQL read block
(cratestack#867; accepted design docs/design/declarative-custom-query.md,
adopted by epic cratestack#488’s 2026-09-02 decision comment).
A query is deliberately not a procedure with a body and not a
parameterized view:
- Unlike
Procedure, it carries a SQL body and is never public wire surface — no REST route, no RPC op id, no generated client stub. That is why it is a separate list onSchemarather than a newProcedurefield: every route/op/client emission site iteratesproceduresandmodels, so a construct they never loop over costs nothing, whereas a flag onProcedurewould need an “is this one internal” branch at five sites (design §1). - Unlike
View, it emits no DDL and creates no persistent database object, and its SQL takes runtime bind parameters — whichCREATE VIEWhas no slot for at all.
The arg list reuses ProcedureArg verbatim rather than defining a
near-identical twin: the policy resolver
(cratestack-macros/src/policy/procedure/resolver.rs) resolves
@allow/@deny predicates purely against an arg list and the schema’s
type declarations, with no model dependency, so sharing the type is
what lets a query reuse it with no new machinery (design §6).
Modules§
- placeholders
- Positional-placeholder scan over a
queryblock’s raw SQL body.
Structs§
Constants§
- QUERY_
SQL_ ATTRIBUTE - The attribute a
queryblock’s SQL body is written in.
Functions§
- scan_
sql_ placeholders - Every distinct
Nin a$Ntoken appearing insqlas an actual parameter reference, ascending.