pub fn compile_query(ast: &QueryAst) -> Result<CompiledQuery, CompileError>Expand description
Compile a QueryAst into a CompiledQuery ready for execution.
§Compilation strategy
The compiled SQL is structured as a WITH RECURSIVE CTE named
base_candidates followed by a final SELECT ... JOIN nodes projection.
For the Nodes driving table (no FTS/vector search), all filter
predicates (LogicalIdEq, JsonPathEq, JsonPathCompare,
SourceRefEq) are pushed into the base_candidates CTE so that the
CTE’s LIMIT applies after filtering. Without this pushdown the LIMIT
would truncate the candidate set before property filters run, silently
excluding nodes whose properties satisfy the filter but whose insertion
order falls outside the limit window.
For FTS and vector driving tables, filters remain in the outer
WHERE clause because the CTE is already narrowed by the search itself.
§Errors
Returns CompileError::TooManyTraversals if more than one traversal step
is present, or CompileError::TooManyBindParameters if the resulting SQL
would require more than 15 bind parameters.
§Panics
Panics (via unreachable!) if the AST is internally inconsistent — for
example, if choose_driving_table selects VecNodes but no
VectorSearch step is present in the AST. This cannot happen through the
public [QueryBuilder] API.