Skip to content

Commit

Permalink
Fix(executor): ensure IN clause can work with a single value (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Jun 21, 2023
1 parent 6a83eaa commit 8079b50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlglot/executor/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class Generator(generator.Generator):
exp.Column: lambda self, e: f"scope[{self.sql(e, 'table') or None}][{self.sql(e.this)}]",
exp.Distinct: lambda self, e: f"set({self.sql(e, 'this')})",
exp.Extract: lambda self, e: f"EXTRACT('{e.name.lower()}', {self.sql(e, 'expression')})",
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)}}}",
exp.Interval: lambda self, e: f"INTERVAL({self.sql(e.this)}, '{self.sql(e.unit)}')",
exp.Is: lambda self, e: self.binary(e, "is"),
exp.Lambda: _lambda_sql,
Expand Down
1 change: 1 addition & 0 deletions tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ def test_scalar_functions(self):
("INTERVAL '1' week", datetime.timedelta(weeks=1)),
("1 IN (1, 2, 3)", True),
("1 IN (2, 3)", False),
("1 IN (1)", True),
("NULL IS NULL", True),
("NULL IS NOT NULL", False),
("NULL = NULL", None),
Expand Down

0 comments on commit 8079b50

Please sign in to comment.