Adding upstream version 25.26.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
7af32ea9ec
commit
dfac4c492f
117 changed files with 49296 additions and 47316 deletions
|
@ -185,6 +185,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.Stream: lambda self, e: f"STREAM {self.sql(e, 'this')}",
|
||||
exp.StreamingTableProperty: lambda *_: "STREAMING",
|
||||
exp.StrictProperty: lambda *_: "STRICT",
|
||||
exp.SwapTable: lambda self, e: f"SWAP WITH {self.sql(e, 'this')}",
|
||||
exp.TemporaryProperty: lambda *_: "TEMPORARY",
|
||||
exp.TagColumnConstraint: lambda self, e: f"TAG ({self.expressions(e, flat=True)})",
|
||||
exp.TitleColumnConstraint: lambda self, e: f"TITLE {self.sql(e, 'this')}",
|
||||
|
@ -200,6 +201,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.ViewAttributeProperty: lambda self, e: f"WITH {self.sql(e, 'this')}",
|
||||
exp.VolatileProperty: lambda *_: "VOLATILE",
|
||||
exp.WithJournalTableProperty: lambda self, e: f"WITH JOURNAL TABLE={self.sql(e, 'this')}",
|
||||
exp.WithProcedureOptions: lambda self, e: f"WITH {self.expressions(e, flat=True)}",
|
||||
exp.WithSchemaBindingProperty: lambda self, e: f"WITH SCHEMA {self.sql(e, 'this')}",
|
||||
exp.WithOperator: lambda self, e: f"{self.sql(e, 'this')} WITH {self.sql(e, 'op')}",
|
||||
}
|
||||
|
@ -564,6 +566,7 @@ class Generator(metaclass=_Generator):
|
|||
exp.VolatileProperty: exp.Properties.Location.POST_CREATE,
|
||||
exp.WithDataProperty: exp.Properties.Location.POST_EXPRESSION,
|
||||
exp.WithJournalTableProperty: exp.Properties.Location.POST_NAME,
|
||||
exp.WithProcedureOptions: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.WithSchemaBindingProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.WithSystemVersioningProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
}
|
||||
|
@ -2144,6 +2147,10 @@ class Generator(metaclass=_Generator):
|
|||
this = expression.this
|
||||
this_sql = self.sql(this)
|
||||
|
||||
exprs = self.expressions(expression)
|
||||
if exprs:
|
||||
this_sql = f"{this_sql},{self.seg(exprs)}"
|
||||
|
||||
if on_sql:
|
||||
on_sql = self.indent(on_sql, skip_first=True)
|
||||
space = self.seg(" " * self.pad) if self.pretty else " "
|
||||
|
@ -2510,13 +2517,16 @@ class Generator(metaclass=_Generator):
|
|||
)
|
||||
kind = ""
|
||||
|
||||
operation_modifiers = self.expressions(expression, key="operation_modifiers", sep=" ")
|
||||
operation_modifiers = f"{self.sep()}{operation_modifiers}" if operation_modifiers else ""
|
||||
|
||||
# We use LIMIT_IS_TOP as a proxy for whether DISTINCT should go first because tsql and Teradata
|
||||
# are the only dialects that use LIMIT_IS_TOP and both place DISTINCT first.
|
||||
top_distinct = f"{distinct}{hint}{top}" if self.LIMIT_IS_TOP else f"{top}{hint}{distinct}"
|
||||
expressions = f"{self.sep()}{expressions}" if expressions else expressions
|
||||
sql = self.query_modifiers(
|
||||
expression,
|
||||
f"SELECT{top_distinct}{kind}{expressions}",
|
||||
f"SELECT{top_distinct}{operation_modifiers}{kind}{expressions}",
|
||||
self.sql(expression, "into", comment=False),
|
||||
self.sql(expression, "from", comment=False),
|
||||
)
|
||||
|
@ -3225,12 +3235,12 @@ class Generator(metaclass=_Generator):
|
|||
expressions = f"({expressions})" if expressions else ""
|
||||
return f"ALTER{compound} SORTKEY {this or expressions}"
|
||||
|
||||
def renametable_sql(self, expression: exp.RenameTable) -> str:
|
||||
def alterrename_sql(self, expression: exp.AlterRename) -> str:
|
||||
if not self.RENAME_TABLE_WITH_DB:
|
||||
# Remove db from tables
|
||||
expression = expression.transform(
|
||||
lambda n: exp.table_(n.this) if isinstance(n, exp.Table) else n
|
||||
).assert_is(exp.RenameTable)
|
||||
).assert_is(exp.AlterRename)
|
||||
this = self.sql(expression, "this")
|
||||
return f"RENAME TO {this}"
|
||||
|
||||
|
@ -3508,13 +3518,15 @@ class Generator(metaclass=_Generator):
|
|||
name = self.normalize_func(name) if normalize else name
|
||||
return f"{name}{prefix}{self.format_args(*args)}{suffix}"
|
||||
|
||||
def format_args(self, *args: t.Optional[str | exp.Expression]) -> str:
|
||||
def format_args(self, *args: t.Optional[str | exp.Expression], sep: str = ", ") -> str:
|
||||
arg_sqls = tuple(
|
||||
self.sql(arg) for arg in args if arg is not None and not isinstance(arg, bool)
|
||||
)
|
||||
if self.pretty and self.too_wide(arg_sqls):
|
||||
return self.indent("\n" + ",\n".join(arg_sqls) + "\n", skip_first=True, skip_last=True)
|
||||
return ", ".join(arg_sqls)
|
||||
return self.indent(
|
||||
"\n" + f"{sep.strip()}\n".join(arg_sqls) + "\n", skip_first=True, skip_last=True
|
||||
)
|
||||
return sep.join(arg_sqls)
|
||||
|
||||
def too_wide(self, args: t.Iterable) -> bool:
|
||||
return sum(len(arg) for arg in args) > self.max_text_width
|
||||
|
@ -3612,7 +3624,7 @@ class Generator(metaclass=_Generator):
|
|||
expressions = (
|
||||
self.wrap(expressions) if expression.args.get("wrapped") else f" {expressions}"
|
||||
)
|
||||
return f"{this}{expressions}"
|
||||
return f"{this}{expressions}" if expressions.strip() != "" else this
|
||||
|
||||
def joinhint_sql(self, expression: exp.JoinHint) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
|
@ -4243,7 +4255,7 @@ class Generator(metaclass=_Generator):
|
|||
else:
|
||||
rhs = self.expressions(expression)
|
||||
|
||||
return self.func(name, expression.this, rhs)
|
||||
return self.func(name, expression.this, rhs or None)
|
||||
|
||||
def converttimezone_sql(self, expression: exp.ConvertTimezone) -> str:
|
||||
if self.SUPPORTS_CONVERT_TIMEZONE:
|
||||
|
@ -4418,3 +4430,7 @@ class Generator(metaclass=_Generator):
|
|||
for_sql = f" FOR {for_sql}" if for_sql else ""
|
||||
|
||||
return f"OVERLAY({this} PLACING {expr} FROM {from_sql}{for_sql})"
|
||||
|
||||
@unsupported_args("format")
|
||||
def todouble_sql(self, expression: exp.ToDouble) -> str:
|
||||
return self.sql(exp.cast(expression.this, exp.DataType.Type.DOUBLE))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue