Repository navigation
feat(spec)!: return a statement's result as a rows type - #184
colinhacks wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
ℹ️ No critical issues — three small rough edges inline.
Reviewed changes
Reviewed the move of a statement descriptor's columns and cardinality into one result of the new rows kind, everywhere the format is written, read and documented.
- Format —
RowsType(cardinality,columns, optionalkeyandordered: true) is appended toType, andStatementDescriptor.resultrefers to it; the schema, the generatedspec/index.tsand the published0.1.0.jsonagree. The version stays0.1.0, and that holds up: thereleasebranch has nospec/typedefs.schema.json, so no released build has served this version. - Engine —
Kind::Rowsis handled inrank,name,collect_names,renamed,short,check_atandjson_schema.Analysis::descriptornow carries thekeyandorderedthe analysis already computed, andreylo analyze's line for a failed statement uses the new shape. - Run time —
descriptor()andrefused()insrc/rtd.tswrite the same shape.withBasesandcolumnKindhandlerows. The.reylo/cache still holdsAnalysis, withcolumnsandcardinalityat the top, solab/compareand the playground, which read that cache, are unaffected. - Tests and docs — every reader of
reylo analyzeoutput is moved toresult.*, includinginstall-check.ts. A new Postgres check showskeyandorderedreachingreylo/rtd. The example and field table inrtd.mdxare updated.
claude-opus-5-5 | 𝕏
There was a problem hiding this comment.
✅ No new issues found. The new commit fixes all three points from the last review.
Reviewed changes
This run covered 64cc401, which tightens how Rust types
8000
a statement's result and adds checks on its key.
- Typed
result:StatementDescriptor::resultis nowResultRows, which serde reads and writes as aType. Deserialization refuses any kind other thanrows, as the schema does. The JSON is unchanged, and a new core test checks both directions. - Key rule check:
check_atforKind::Rowsnow refuses akeythat names a column the result doesn't have. It also refuses akeyon rows whose cardinality isn'tmany. This matches what the engine emits: Postgres'sresult_keyreturnsNoneunless the result ismanyrows, and the other engines writekey: None. - Docs: the
resultrow inrtd.mdxnow says whatkeyandorderedmean.
claude-opus-5-5 | 𝕏
A result of another kind now fails to deserialize, as it fails the schema, and the rule check holds a key to its columns and cardinality. The rtd page says what key and ordered mean.
64cc401 to
6b19b18
Compare
There was a problem hiding this comment.
✅ No new issues found. The rebase onto
maincarries the change over cleanly.
Reviewed changes
Since 64cc401, the branch was rebased onto main after #191, which renamed reylo analyze to reylo compile. The PR's own changes now sit on the renamed files.
- Renamed paths: the
resultshape now lives insrc/compile.ts(descriptor()andrefused()),engine/cli/src/compile.rs,tests/compile-cli.test.ts,tests/compile.test.ts,tests/cli.test.ts,tests/connect.test.tsand.github/scripts/install-check.ts. Every reader there usesresult.columnsandresult.cardinality. I found no remaining reader of the old top-level fields insrc/, the skill or the docs. - Core: the
Kind::Unionarm inrenamednow matches theUnionTypefrommain, which no longer has a second field.ResultRowsand thekeychecks from the previous commit are unchanged. - Docs: the example in
08c-api.mdxuses therowsshape. The page onmainhas no field table, sokeyandorderedare explained only in the JSON Schema it links to. - Format text: the
StatementDescriptordescription in the schema,spec/index.tsand the published0.1.0.jsonnow namesreylo compile.
claude-opus-5-5 | 𝕏

A statement descriptor's
columnsandcardinalitybecome oneresult, of a new kind for tabular data,rows, which also carries the two facts Reylo infers about a result and the format didn't hold: its key and whether its order is total.{ "$schema": "https://reylo.dev/typedefs/0.1.0.json", "dialect": { "name": "postgres", "version": "18.6" }, "sql": "select id, email from users order by id", "kind": "select", "params": [], "result": { "kind": "rows", "cardinality": "many", "columns": [ { "name": "id", "type": { "kind": "integer", "bits": 64, "name": "int8" } }, { "name": "email", "type": { "kind": "text", "size": { "max": 255 }, "name": "varchar" } } ], "key": ["id"], "ordered": true }, "diagnostics": [] }RowsTypeiskind: "rows"withcardinality,columns, and where they're knownkeyandordered. It is appended toType, since a relation nested in a value (SQL'sMULTISET, an Oracle nested table) is the same shape; no engine writes a nested one yet. A statement that returns one value is still a row of one column, which keeps the column's name, as.run()does.spec/typedefs.schema.json, thennub run typedefsforspec/index.tsand the published0.1.0.json. The version stays 0.1.0: no release has published it.Kind::RowsandStatementDescriptor::resultinengine/core/src/types.rs;Analysis::descriptorandreylo analyze's line for a failed statement write it. What the engine answers the loader is unchanged, so no declaration and no.run()result changes: only whatreylo analyzeandreylo/rtdreturn.descriptor()andrefused()insrc/rtd.tswrite the same shape, andtests/rtd.test.tsstill holds them toreylo analyzefield by field, with a new check thatkeyandorderedreach it on Postgres.install-check.ts, which reads a descriptor.Verified
cargo build --workspace --all-targetswith no warning; every crate's tests.nub run typecheck, andnub run testagainst Postgres 18 and MySQL 8.4 on the release binary: 352 passed, none skipped.nub run buildinsite/.