Expand description
Parameter binding for :name / ? placeholders with type-checked
substitution.
Parameter binding and prepared query substitution.
Provides type-safe substitution of named (:name) and positional (?)
parameter placeholders in QQL query text.
§Placeholders & Syntax Rules
- Named placeholders:
:name(e.g.:category,:limit). - Positional placeholders:
?(sequential 1-to-1 mapping with parameters list).
In QQL, $ is a first-class identifier character (e.g. $category, $1), so
parameter placeholders exclusively use :name and ?. This guarantees that
$-prefixed identifiers in queries are never accidentally or silently rewritten.
Furthermore, a colon : is only recognized as a parameter placeholder when it occurs
at a valid token boundary (preceded by whitespace, punctuation, or start of query).
Colons in compact dictionary syntax (e.g. {a:b}, {'a':b}) are not placeholders
and are preserved without modification. Note that unconventional spacing with whitespace
before the colon ({a :b}) makes :b lexically indistinguishable from a placeholder.
Literals and dictionary keys are safely formatted and escaped to prevent
query injection breakouts. String literals ('...', r'...', """...""",
and `...`) and comments (-- ...) in the source query are preserved
verbatim and never substituted.
params (typed Value) and params_json (JSON serde_json::Value) are
dual contracts that must stay in lockstep: a binding-rule fix in one must
be ported to the other. JSON is the host-SDK round-trip; typed Value is
the zero-copy FFI fast path (F32Array, packed multivector).
Functions§
- bind_
filter - Recursively bind parameters into a
FilterExprin-place. - bind_
formula - Recursively bind parameters into a
FormulaExprin-place. - bind_
named - Substitute named parameters (
:name) intosource. - bind_
named_ readable - Substitute named parameters (
:name) intosource, truncating long vector literals for readable preview. - bind_
page_ spec - Bind parameters into a
PageSpecin-place. - bind_
point_ id - Bind parameters into a
PointIdin-place. - bind_
point_ selector - Bind parameters into a
PointSelectorin-place. - bind_
positional - Substitute positional parameters (
?) sequentially intosource. - bind_
positional_ readable - Substitute positional parameters (
?) sequentially intosource, truncating long vector literals for readable preview. - bind_
query_ expr - Recursively bind parameters into a
QueryExprin-place. - bind_
query_ input - Recursively bind parameters into a
QueryInputin-place. - bind_
query_ stmt - Recursively bind parameters into a
QueryStmtin-place. - bind_
shard_ key - Bind parameters into a routing
ShardKeyin-place. - bind_
stmt - Bind parameters into a parsed AST
Stmtin-place. - bind_
value - Recursively bind parameters into an AST
Valuein-place. - collect_
statement_ params - Collect all named parameter names and the maximum positional parameter index present anywhere in a statement AST.
- escape_
str_ literal - Escape a string literal for QQL single-quoted representation.
- ident_
at - ASCII identifier slice at
[start, end). Infallible because the scanner only advances overis_ident_start/is_ident_continuebytes. - is_
ident_ continue - Check if a byte is a valid parameter identifier continue character.
- is_
ident_ start - Check if a byte is a valid parameter identifier start character.
- is_
placeholder_ start - Returns true if the
:at byte offsetiis at a valid token boundary to begin a parameter placeholder. - resolve_
param_ u64 - Resolve a parameter string (
:nameor?N) to au64. - skip_
protected - If
bytes[i]begins a comment, string literal, or backtick identifier, returnsSome(next_offset)skipping the protected region. OtherwiseNone. - stmt_
has_ point_ params - Whether an upsert template carries whole-point placeholders (
VALUES :p/VALUES ?) needing dict splice at execution time. - truncate_
vector_ literals - Truncate long numeric vector literals inside a QQL query string for compact preview.
- validate_
no_ unbound_ params - Verify that a statement contains no unbound parameters, without cloning the AST.
- validate_
no_ unbound_ scalar_ params - Verify that a statement contains no unbound scalar parameters, allowing
vector parameter placeholders (
VectorValue::Param,PointVectors::Param,QueryInput::Param). ReturnsOk(true)if vector parameters exist. - value_
to_ literal - Convert an AST
Valueinto its canonical, safely escaped QQL literal string.