8000 feat(sqlite): pin subqueries, with queries and views by their keys by colinhacks · Pull Request #106 · colinhacks/reylo · GitHub
[go: up one dir, main page]

Skip to content

feat(sqlite): pin subqueries, with queries and views by their keys - #106

Merged
colinhacks merged 3 commits into
mainfrom
subquery-keys-sqlite
Oct 24, 2026
Merged

colinhacks merged 3 commits into
mainfrom
subquery-keys-sqlite

Conversation

@colinhacks
Copy link
Copy Markdown
Owner

A subquery, a WITH query or a view is now pinned to one row by a unique key of its rows on SQLite, as a table is by its index. select * from (select id, title from posts) s where s.id = :id was many and is now maybeOne, and so are the WITH and view forms. This is the rule #105 adds on Postgres, over SQLite's resolved tree.

The rule

A set of a subquery's output columns is a key of its rows when either:

  • one of its FROM items has a unique key the select list keeps unchanged, and every other item is pinned to one row per row of that item (the closure the proof already computes, seeded with that item); or
  • its GROUP BY names those columns, or it is a DISTINCT whose every column is a column of its FROM.

The outer equalities then pin the subquery by that key under the same checks a table's key gets: a value that reads only pinned items, nothing volatile, no COLLATE, a comparison that leaves the column's values as they are, and a collation the key holds to.

A set operation, VALUES, a key column passed through an expression or a cast, a join to a table that is not pinned, and a RIGHT or FULL JOIN give no key.

SQLite's resolved tree already holds a view as the subquery it is, so views need nothing more.

Checks

  • oracle/cases/sqlite_subquery_keys: 49 statements, run over seeded edge values with no contradiction.
  • Every SQLite oracle case passes with --strict-coverage. One existing answer moves, sqlite_functions/view.sql, a view that passes id through, read by it: many to maybeOne.
  • A new unit test covers the rule and its refusals.
  • nub run test with both test databases: 251 pass, none skipped. The docs state the rule in the SQLite page's cardinality section.

Copilot AI balanced review requested due to automatic review settings October 24, 2026 00:59
@vercel
vercel Bot commented Oct 24, 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 Oct 24, 2026 1:13am UTC

Request Review

@pullfrog
pullfrog Bot commented Oct 24, 2026 •
Copy link
Copy Markdown
Contributor

No configured credential can serve this run. Your Claude Pro/Max subscription has hit its usage limit, which resets at 2026-10-26 08:00 UTC. Re-trigger after it resets, or add an API key for this provider, which Pullfrog falls back to automatically.

The providers' responses
CLAUDE_CODE_OAUTH_TOKEN: 429: This request would exceed your account's rate limit. Please try again later.

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using claude-opus-5-5

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.

@colinhacks
colinhacks force-pushed the subquery-keys-sqlite branch from 4764206 to 52fe137 Compare October 24, 2026 01:12
@pullfrog
pullfrog Bot commented Oct 24, 2026
Copy link
Copy Markdown
Contributor

No configured credential can serve this run. Your Claude Pro/Max subscription has hit its usage limit, which resets at 2026-10-26 08:00 UTC. Re-trigger after it resets, or add an API key for this provider, which Pullfrog falls back to automatically.

The providers' responses
CLAUDE_CODE_OAUTH_TOKEN: 429: This request would exceed your account's rate limit. Please try again later.

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using claude-opus-5-5

@colinhacks
colinhacks merged commit 214f97b into main Oct 24, 2026
6 of 7 checks passed
@colinhacks
colinhacks deleted the subquery-keys-sqlite branch October 24, 2026 01:15
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