Skip to content

fix(parser): prioritize parsing parenthesized expressions as Tuple when multi-expression CSV exists - #7807

Merged
georgesittas merged 1 commit into
tobymao:mainfrom
Hasnaathussain:fix/7805-sqlite-in-nested-tuple
Jun 29, 2026
Merged

georgesittas merged 1 commit into
tobymao:mainfrom
Hasnaathussain:fix/7805-sqlite-in-nested-tuple

Conversation

@Hasnaathussain

@Hasnaathussain Hasnaathussain commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

When parsing parenthesized expressions where the first item is a subquery (e.g. ((SELECT 42), 1)), the parser's _parse_paren method matches the isinstance(this, (exp.Subquery, exp.Values)) check first and constructs a Subquery object, dropping subsequent items (such as , 1).

This PR fixes this by checking if the CSV contains multiple expressions (i.e., len(expressions) > 1 or a trailing comma) first, which constructs an exp.Tuple and correctly preserves all elements.

I have added a unit test verifying that ((SELECT 42), 1) parses as a Tuple successfully.

Closes #7805

Copilot AI review requested due to automatic review settings June 28, 2026 09:42

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@georgesittas georgesittas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@georgesittas
georgesittas merged commit 287cc39 into tobymao:main Jun 29, 2026
10 checks passed
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.

Value disappeared when parsing sql in sqlite with expression IN

3 participants