Skip to main content

Module sql

Module sql 

Source
Expand description

Compile GQL AST to parameterized SQL.

Two compilation paths:

  • Fixed-length patterns (all edges *1..1) → JOIN chain
  • Variable-length patterns (any edge *N..M where M>1) → recursive CTE

Synthetic edge paths (ADR-041):

  • Relations prefixed observed_as_* join against event_observations, not graph_edges.

Security invariants (MAJ-1/MAJ-2/MAJ-3 from critic review):

  • Namespace injection: WHERE clause always comes from CompileOptions.scopes, never the query.
  • Edge property whitelist: only relation and weight are queryable edge columns.
  • Depth cap: recursive CTE depth capped at MAX_DEPTH; exceeding it errors at validation.

Structs§

CompileOptions
CompiledQuery

Functions§

compile