Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(executor): ensure IN clause can work with a single value #1815

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

georgesittas
Copy link
Collaborator

exp.In: lambda self, e: f"{self.sql(e, 'this')} in ({self.expressions(e, flat=True)})",
exp.In: lambda self, e: f"{self.sql(e, 'this')} in {{{self.expressions(e, flat=True)}}}",
Copy link
Collaborator Author

@georgesittas georgesittas Jun 21, 2023

Choose a reason for hiding this comment

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

I've silently assumed that the order of evaluation of the IN clause is arbitrary here, hence the set. If that's not the case for some reason, we can instead do:

            exp.In: lambda self, e: f"{self.sql(e, 'this')} in ({self.expressions(e, flat=True)},)",

This will always add a trailing comma, resulting in a tuple instead of a parenthesized integer, so it will solve the case where we have a single item to iterate over.

@tobymao tobymao merged commit 8079b50 into main Jun 21, 2023
@tobymao tobymao deleted the jo/fix_executor_in_clause branch June 21, 2023 15:43
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.

Evaluated macro condition errors when SQL IN operator has array length 1
2 participants