Skip to content

Unrecognized statements produce an empty-name strict error message #303

Description

@tiagolauer

Statements the parser does not recognize error out with an empty-name message in strict mode:

StrictRow<DB, 'truncate users'>   // QueryTypeError<'unknown table: '>
StrictRow<DB, 'selct id from users'> // same - a keyword typo reported as a table problem
StrictRow<DB, ''>                 // same

Failing loudly is right. The message is the problem: it names no table, and it points a selct typo at entirely the wrong layer. Something like QueryTypeError<'unsupported or unrecognized statement'> would send the user to the actual mistake.

Root cause: ParseStatementNormalized resolves to never for unmatched keywords (src/parse.ts:348), and that never flows into StarRow/FirstUnknownTable, whose base case returns '' (src/parse.ts:516-521 and 799). Non-strict mode gives { [x: string]: unknown }[] and ParseStatement itself is a clean never, so only the strict message needs attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions