Merging upstream version 25.21.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
80aea2cba8
commit
34f177b0b3
105 changed files with 50314 additions and 49385 deletions
|
@ -329,7 +329,11 @@ class MySQL(Dialect):
|
|||
|
||||
FUNCTION_PARSERS = {
|
||||
**parser.Parser.FUNCTION_PARSERS,
|
||||
"CHAR": lambda self: self._parse_chr(),
|
||||
"CHAR": lambda self: self.expression(
|
||||
exp.Chr,
|
||||
expressions=self._parse_csv(self._parse_assignment),
|
||||
charset=self._match(TokenType.USING) and self._parse_var(),
|
||||
),
|
||||
"GROUP_CONCAT": lambda self: self._parse_group_concat(),
|
||||
# https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_values
|
||||
"VALUES": lambda self: self.expression(
|
||||
|
@ -620,18 +624,6 @@ class MySQL(Dialect):
|
|||
parse_interval=parse_interval, fallback_to_identifier=fallback_to_identifier
|
||||
)
|
||||
|
||||
def _parse_chr(self) -> t.Optional[exp.Expression]:
|
||||
expressions = self._parse_csv(self._parse_assignment)
|
||||
kwargs: t.Dict[str, t.Any] = {"this": seq_get(expressions, 0)}
|
||||
|
||||
if len(expressions) > 1:
|
||||
kwargs["expressions"] = expressions[1:]
|
||||
|
||||
if self._match(TokenType.USING):
|
||||
kwargs["charset"] = self._parse_var()
|
||||
|
||||
return self.expression(exp.Chr, **kwargs)
|
||||
|
||||
def _parse_group_concat(self) -> t.Optional[exp.Expression]:
|
||||
def concat_exprs(
|
||||
node: t.Optional[exp.Expression], exprs: t.List[exp.Expression]
|
||||
|
@ -698,6 +690,7 @@ class MySQL(Dialect):
|
|||
PARSE_JSON_NAME: t.Optional[str] = None
|
||||
PAD_FILL_PATTERN_IS_REQUIRED = True
|
||||
WRAP_DERIVED_VALUES = False
|
||||
VARCHAR_REQUIRES_SIZE = True
|
||||
|
||||
TRANSFORMS = {
|
||||
**generator.Generator.TRANSFORMS,
|
||||
|
@ -1125,10 +1118,19 @@ class MySQL(Dialect):
|
|||
return super().extract_sql(expression)
|
||||
|
||||
def datatype_sql(self, expression: exp.DataType) -> str:
|
||||
if (
|
||||
self.VARCHAR_REQUIRES_SIZE
|
||||
and expression.is_type(exp.DataType.Type.VARCHAR)
|
||||
and not expression.expressions
|
||||
):
|
||||
# `VARCHAR` must always have a size - if it doesn't, we always generate `TEXT`
|
||||
return "TEXT"
|
||||
|
||||
# https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
|
||||
result = super().datatype_sql(expression)
|
||||
if expression.this in self.UNSIGNED_TYPE_MAPPING:
|
||||
result = f"{result} UNSIGNED"
|
||||
|
||||
return result
|
||||
|
||||
def jsonarraycontains_sql(self, expression: exp.JSONArrayContains) -> str:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue