Documentation
¶
Overview ¶
ormgen check --lang php <dir>: what a PHP codebase uses that the compatibility layer (docs/dsl.md §6) must translate. A report, not a linter: counts per token family, the files that open/close '(' tokens across models, and expr fragments with backtick column names (docs/checklist.md T4.7).
ormgen check --lang go: the fragments Go code passes to expr/selectExpr/raw are raw SQL the engine only sees at run time. This walks the sources and checks what can be checked statically: every backtick-quoted name must exist as a column somewhere in the manifest, and the `?` count must match the binds given at the call site (when they are not a spread).
A line carrying (or preceded by) a comment with `ormgen:ignore` is skipped — for the tests that deliberately pass a bad fragment to see the engine reject it.
ormgen ddl: manifest → CREATE TABLE statements for one dialect (docs/dialects.md).
ormgen ddl --schema schema/schema.json --dialect mysql|postgres|sqlite --out bench/sql/battle.pg.sql
Types come from the canonical manifest types (plus the raw MySQL type where it carries precision); indexes, unique keys and fulltext indexes are emitted as the dialect supports them. Data seeding stays with the bench scripts.
ormgen errors: docs/errors.yaml → one constants file per language, so every client names the same codes (docs/checklist.md T5.2). The yaml is a flat list; no YAML library is needed.
ormgen errors --lang go --out clients/go/orm/codes.go ormgen errors --lang php --out clients/php/src/Code.php ormgen errors --lang rust --out clients/rust/orm/src/codes.rs
ormgen import: a live MySQL schema → Mermaid erDiagram (docs/schema.md).
ormgen import --dsn "root@unix(/tmp/mysql.sock)/orm_bench" --out schema/app.mmd [--tables a,b]
Deterministic (tables alphabetical, columns by ordinal position) so a re-import of an unchanged database is a no-op diff. When --out already exists, hand-written facts that the database cannot express are carried over: relation name overrides "(child / parent)", column attributes lazy / bool / int / explicit styles, and %% predicate lines.
ormgen: schema tooling. S1 scope: build (Mermaid → schema.json).
ormgen build <schema/*.mmd...> --out schema/schema.json
ormgen tokens: parity lint. Extracts the statement tokens (heads, predicates, joins, terminals, …) from Go/PHP/Rust/TypeScript sources, maps each language's spelling back to the canonical camelCase token, and diffs the sequences. Sources that express the same statements must produce identical token streams.
ormgen tokens --schema schema/schema.json [--print] a.go b.php c.rs
ormgen validate: does the live database still match the manifest the clients were generated from?
ormgen validate --dsn "root@unix(/tmp/mysql.sock)/orm_bench" --schema schema/schema.json
Exit status 1 with one line per difference (CI gate, docs/checklist.md T5.1). The comparison is at the canonical level the clients see: entity/table presence, column set and order, canonical type, nullability, auto-increment, style stack (from the column name, so a rename shows up).