Expand description
validate_query_as — the single entry point for query_as! validation.
Algorithm:
- Look up
struct_namein the registry viaget_by_struct; if absent →StructNotRegistered. This returns the SQL table name alongside the entry (struct ident ≠ SQL table name in general). - Run the
LIMIT 0dry-run. - On success: compute name-subset diff (struct fields ⊆ result columns).
- On
42P01(undefined_table): extract the SQL table name from the error, seed from registry if known (then retry once), or emitTablesNotRegistered. - On
42703(undefined_column) or42601(syntax): forward as diagnostics.
§Key design note: struct name vs. table name
The registry is dual-indexed: by SQL table name (for 42P01 seed-and-retry,
which receives the SQL name from Hyper) and by Rust struct ident (for the
initial lookup, since query_as!(User, …) passes “User”, not “users”).
validate_query_as always receives the struct ident; Registry::seed_if_known
always receives the SQL table name from Hyper’s error.
No syn/quote/proc-macro2 types in this module’s public API.
Functions§
- validate_
query_ as - Validate that
sqlis structurally compatible withstruct_name. - validate_
scalar_ sql - Validate a scalar SQL string: runs the dry-run and checks the result
projects exactly one column. Used by
query_scalar!.