fix(parse): name an unrecognized statement in strict mode - #344
Merged
Conversation
StrictRow<DB, 'truncate users'> // was never
StrictRow<DB, 'selct id from users'> // was never
StrictRow<DB, ''> // was never
Failing is right - there is no row to produce - but `never` explains
nothing, and the reported symptom was worse: before the #275 guard landed,
the never flowed into StarRow/FirstUnknownTable and came out as
`unknown table: ''`, a message naming no table and pointing a keyword typo
at entirely the wrong layer.
Strict mode now reports `unsupported or unrecognized statement`, alongside
the multiple-statements error that already reads this way. Loose mode keeps
returning never rather than degrading into an index signature, which is what
Fixes #303
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tiagolauer
force-pushed
the
fix/303-unrecognized-statement
branch
from
August 2, 2026 13:04
8d6ee75 to
ab7d2e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #303.
The bug
Failing loudly is right. The message is the problem — and on the version the issue was filed against it was
QueryTypeError<'unknown table: ''>, which names no table and points aselcttypo at entirely the wrong layer. The[never]guard from #275 has since turned that into a barenever, which is honest but still explains nothing.The fix
Strict mode reports
QueryTypeError<'unsupported or unrecognized statement'>, in the same shape as the multiple-statements error the parser already produces.Loose mode keeps returning
neverrather than degrading into{ [x: string]: unknown }, which is what #275 deliberately put in place — a query the parser cannot read should not come back looking like a successful parse.Verification
tests/unrecognized-statement.test-d.ts, nine cases. Four red on master:truncate users, theselcttypo and the empty query, through bothStrictRowandStrictQueryneverControls: a plain SELECT, an UPDATE with RETURNING, the stacked-statement error, and loose mode on a valid query are all unchanged.
tsc --noEmitclean, 192 runtime tests pass, budget 191,574 (912 below master — the strict branch replaces work the never path was doing downstream).