8000 feat(spec)!: return a statement's result as a rows type by colinhacks · Pull Request #184 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

feat(spec)!: return a statement's result as a rows type - #184

Open
colinhacks wants to merge 2 commits into
mainfrom
typedefs-rows
Open

colinhacks wants to merge 2 commits into
mainfrom
typedefs-rows

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

A statement descriptor's columns and cardinality become one result, 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": []
}
  • The kind. RowsType is kind: "rows" with cardinality, columns, and where they're known key and ordered. It is appended to Type, since a relation nested in a value (SQL's MULTISET, 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.
  • The format. spec/typedefs.schema.json, then nub run typedefs for spec/index.ts and the published 0.1.0.json. The version stays 0.1.0: no release has published it.
  • The engine. Kind::Rows and StatementDescriptor::result in engine/core/src/types.rs; Analysis::descriptor and reylo 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 what reylo analyze and reylo/rtd return.
  • The API. descriptor() and refused() in src/rtd.ts write the same shape, and tests/rtd.test.ts still holds them to reylo analyze field by field, with a new check that key and ordered reach it on Postgres.
  • Docs. The API page's example and field table, and install-check.ts, which reads a descriptor.

Verified

  • cargo build --workspace --all-targets with no warning; every crate's tests.
  • nub run typecheck, and nub run test against Postgres 18 and MySQL 8.4 on the release binary: 352 passed, none skipped.
  • nub run build in site/.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 01:16
@vercel
vercel Bot commented Nov 5, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reylo Ready Ready Preview Nov 5, 2026 6:52pm UTC

Request Review

Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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, optional key and ordered: true) is appended to Type, and StatementDescriptor.result refers to it; the schema, the generated spec/index.ts and the published 0.1.0.json agree. The version stays 0.1.0, and that holds up: the release branch has no spec/typedefs.schema.json, so no released build has served this version.
  • Engine — Kind::Rows is handled in rank, name, collect_names, renamed, short, check_at and json_schema. Analysis::descriptor now carries the key and ordered the analysis already computed, and reylo analyze's line for a failed statement uses the new shape.
  • Run time — descriptor() and refused() in src/rtd.ts write the same shape. withBases and columnKind handle rows. The .reylo/ cache still holds Analysis, with columns and cardinality at the top, so lab/compare and the playground, which read that cache, are unaffected.
  • Tests and docs — every reader of reylo analyze output is moved to result.*, including install-check.ts. A new Postgres check shows key and ordered reaching reylo/rtd. The example and field table in rtd.mdx are updated.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread engine/core/src/types.rs Resolved
Comment thread engine/core/src/types.rs Resolved
Comment thread site/content/docs/rtd.mdx Resolved
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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::result is now ResultRows, which serde reads and writes as a Type. Deserialization refuses any kind other than rows, as the schema does. The JSON is unchanged, and a new core test checks both directions.
  • Key rule check: check_at for Kind::Rows now refuses a key that names a column the result doesn't have. It also refuses a key on rows whose cardinality isn't many. This matches what the engine emits: Postgres's result_key returns None unless the result is many rows, and the other engines write key: None.
  • Docs: the result row in rtd.mdx now says what key and ordered mean.

Pullfrog  | View workflow run | Using 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.
@pullfrog pullfrog Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. The rebase onto main carries 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 result shape now lives in src/compile.ts (descriptor() and refused()), engine/cli/src/compile.rs, tests/compile-cli.test.ts, tests/compile.test.ts, tests/cli.test.ts, tests/connect.test.ts and .github/scripts/install-check.ts. Every reader there uses result.columns and result.cardinality. I found no remaining reader of the old top-level fields in src/, the skill or the docs.
  • Core: the Kind::Union arm in renamed now matches the UnionType from main, which no longer has a second field. ResultRows and the key checks from the previous commit are unchanged.
  • Docs: the example in 08c-api.mdx uses the rows shape. The page on main has no field table, so key and ordered are explained only in the JSON Schema it links to.
  • Format text: the StatementDescriptor description in the schema, spec/index.ts and the published 0.1.0.json now names reylo compile.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0