Expand description
Post-build schema validation.
walk() (the Python schema builder) checks structure — duplicate names,
dangling references, link cycles, interface conformance — but every PyQL
body embedded in the schema (function bodies, computed pointers,
defaults, mutation rewrites, triggers, aliases, computed globals) used to
only ever get compiled lazily, the first time something actually
exercised it (a query, a migration, a DDL export) — so a broken one could
sit undetected in the schema indefinitely. This module closes that gap by
eagerly compiling every one of them at finalize() time.
Two kinds of check:
-
Type consistency (functions, computed pointers, defaults, rewrites) — the body compiles and its inferred return type matches what’s declared. A body that does not compile at all is an error here, not a skip: nothing downstream re-reports it, because
export’scolumn_defaultanddiff’sresolve_defaultboth drop an uncompilable default with.ok(), which is how a pointer declaredDefault('std::uuid_generate_v7j()')— a function that does not exist — used to reach Postgres as a column with no default at all and fail on the first insert instead.The type half is still not exhaustive:
infer_ir_typetypes what it recognizes (column refs, casts, literals, enum members, named tuples, function params, global params, slices, arithmetic, and any function call whose resolution recorded a scalar return type) and anything it cannot type is skipped rather than rejected. -
Compile-only (triggers, aliases, computed globals) — these have no single declared scalar type to compare against (a trigger handler is void, an alias/computed-global can select any shape), so only “does it compile” is checked.
Functions§
- validate_
partitions - Validates every
Partitiondeclaration inschema. - validate_
schema_ types - Compile every user function body, computed-pointer expression, and
property/link default in
schema, and collect every declared-vs-actual return-type mismatch found — not fail-fast, so a caller can report every problem in the schema at once rather than a fix-one-rerun loop. Partition declarations (validate_partitions) are checked in the same pass, for the same reason.