Skip to content

Parenthesized set-op branches produce a garbage row type #275

Description

@tiagolauer

Wrapping set-op branches in parentheses, the standard form for per-branch ORDER BY or LIMIT, produces garbage instead of a row type:

Query<DB, '(select id from users) union (select id from archived_users)'>
// { [x: string]: unknown }[]
// strict: QueryTypeError<'unknown table: '>[] - note the empty table name

Expected { id: number }[]. This is valid in every dialect and the README claims UNION support.

Root cause, in two layers. ParseStatementNormalized (src/parse.ts:306-349) requires the first word to be a statement keyword, and (select matches nothing, so the parse is never. Then InferRowWithChecked (src/parse.ts:965-970) has no [never] guard: never extends { columns: infer ... } succeeds with every infer position resolving to never, which yields the index-signature row instead of a clean failure. That second layer is the same never extends {...} pattern behind #229 and the #243 batch, surfacing in one more spot.

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