Skip to content

Commit

Permalink
Fix: make end transactions postgres specific closes #1921
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Jul 14, 2023
1 parent cc33749 commit 35e05f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions sqlglot/dialects/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ class Parser(parser.Parser):
TokenType.LT_AT: binary_range_parser(exp.ArrayContained),
}

STATEMENT_PARSERS = {
**parser.Parser.STATEMENT_PARSERS,
TokenType.END: lambda self: self._parse_commit_or_rollback(),
}

def _parse_factor(self) -> t.Optional[exp.Expression]:
return self._parse_tokens(self._parse_exponent, self.FACTOR)

Expand Down
1 change: 0 additions & 1 deletion sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ class Parser(metaclass=_Parser):
TokenType.DESC: lambda self: self._parse_describe(),
TokenType.DESCRIBE: lambda self: self._parse_describe(),
TokenType.DROP: lambda self: self._parse_drop(),
TokenType.END: lambda self: self._parse_commit_or_rollback(),
TokenType.FROM: lambda self: exp.select("*").from_(
t.cast(exp.From, self._parse_from(skip_from_token=True))
),
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/identity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ map.x
SELECT update
SELECT x.update
SELECT call.x
SELECT end
a.b.INT(1.234)
INT(x / 100)
time * 100
Expand Down

0 comments on commit 35e05f7

Please sign in to comment.