Skip to content

Commit

Permalink
feat: add parse into tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Dec 10, 2024
1 parent ddf7483 commit 5a276f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ class Parser(metaclass=_Parser):
exp.Sort: lambda self: self._parse_sort(exp.Sort, TokenType.SORT_BY),
exp.Table: lambda self: self._parse_table_parts(),
exp.TableAlias: lambda self: self._parse_table_alias(),
exp.Tuple: lambda self: self._parse_value(),
exp.When: lambda self: seq_get(self._parse_when_matched(), 0),
exp.Where: lambda self: self._parse_where(),
exp.Window: lambda self: self._parse_named_window(),
Expand Down
4 changes: 4 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def test_parse_empty(self):
parse_one("")

def test_parse_into(self):
self.assertIsInstance(parse_one("(1)", into=exp.Tuple), exp.Tuple)
self.assertIsInstance(parse_one("(1,)", into=exp.Tuple), exp.Tuple)
self.assertIsInstance(parse_one("(x=1)", into=exp.Tuple), exp.Tuple)

self.assertIsInstance(parse_one("select * from t", into=exp.Select), exp.Select)
self.assertIsInstance(parse_one("select * from t limit 5", into=exp.Select), exp.Select)
self.assertIsInstance(parse_one("left join foo", into=exp.Join), exp.Join)
Expand Down

0 comments on commit 5a276f3

Please sign in to comment.