Skip to content

Commit 302373d

Browse files
committed
handle BINARY keyword in mysql
1 parent 7f2a74c commit 302373d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

sqlglot/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6877,7 +6877,7 @@ def _parse_convert(
68776877

68786878
if self._match(TokenType.USING):
68796879
to: t.Optional[exp.Expression] = self.expression(
6880-
exp.CharacterSet, this=self._parse_var()
6880+
exp.CharacterSet, this=self._parse_var(tokens={TokenType.BINARY})
68816881
)
68826882
elif self._match(TokenType.COMMA):
68836883
to = self._parse_types()

tests/dialects/test_mysql.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ def test_convert(self):
573573
"mysql": "CAST(x AS CHAR CHARACTER SET latin1)",
574574
},
575575
)
576+
self.validate_identity(
577+
"CONVERT('a' USING binary)", "CAST('a' AS CHAR CHARACTER SET binary)"
578+
)
576579

577580
def test_match_against(self):
578581
self.validate_all(

0 commit comments

Comments
 (0)