Merging upstream version 25.24.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
a52cca819a
commit
a43c78d8b5
75 changed files with 43236 additions and 41203 deletions
|
@ -192,7 +192,6 @@ class Generator(metaclass=_Generator):
|
|||
exp.TransientProperty: lambda *_: "TRANSIENT",
|
||||
exp.Union: lambda self, e: self.set_operations(e),
|
||||
exp.UnloggedProperty: lambda *_: "UNLOGGED",
|
||||
exp.UnpackColumns: lambda self, e: f"*{self.sql(e.this)}",
|
||||
exp.Uuid: lambda *_: "UUID()",
|
||||
exp.UppercaseColumnConstraint: lambda *_: "UPPERCASE",
|
||||
exp.VarMap: lambda self, e: self.func("MAP", e.args["keys"], e.args["values"]),
|
||||
|
@ -2002,7 +2001,8 @@ class Generator(metaclass=_Generator):
|
|||
values = f"VALUES{self.seg('')}{args}"
|
||||
values = (
|
||||
f"({values})"
|
||||
if self.WRAP_DERIVED_VALUES and (alias or isinstance(expression.parent, exp.From))
|
||||
if self.WRAP_DERIVED_VALUES
|
||||
and (alias or isinstance(expression.parent, (exp.From, exp.Table)))
|
||||
else values
|
||||
)
|
||||
return f"{values} AS {alias}" if alias else values
|
||||
|
@ -3625,13 +3625,15 @@ class Generator(metaclass=_Generator):
|
|||
using = f"USING {self.sql(expression, 'using')}"
|
||||
on = f"ON {self.sql(expression, 'on')}"
|
||||
expressions = self.expressions(expression, sep=" ", indent=False)
|
||||
returning = self.sql(expression, "returning")
|
||||
if returning:
|
||||
expressions = f"{expressions}{returning}"
|
||||
|
||||
sep = self.sep()
|
||||
returning = self.expressions(expression, key="returning", indent=False)
|
||||
returning = f"RETURNING {returning}" if returning else ""
|
||||
|
||||
return self.prepend_ctes(
|
||||
expression,
|
||||
f"MERGE INTO {this}{table_alias}{sep}{using}{sep}{on}{sep}{expressions}{sep}{returning}",
|
||||
f"MERGE INTO {this}{table_alias}{sep}{using}{sep}{on}{sep}{expressions}",
|
||||
)
|
||||
|
||||
@unsupported_args("format")
|
||||
|
@ -4323,6 +4325,65 @@ class Generator(metaclass=_Generator):
|
|||
parent_cond = parent.expression.this
|
||||
parent_cond.replace(parent_cond.and_(expression.this.is_(exp.null()).not_()))
|
||||
else:
|
||||
array_agg = f"{array_agg} FILTER(WHERE {self.sql(expression, 'this')} IS NOT NULL)"
|
||||
# DISTINCT is already present in the agg function, do not propagate it to FILTER as well
|
||||
this = expression.this
|
||||
this_sql = (
|
||||
self.expressions(this)
|
||||
if isinstance(this, exp.Distinct)
|
||||
else self.sql(expression, "this")
|
||||
)
|
||||
array_agg = f"{array_agg} FILTER(WHERE {this_sql} IS NOT NULL)"
|
||||
|
||||
return array_agg
|
||||
|
||||
def apply_sql(self, expression: exp.Apply) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
expr = self.sql(expression, "expression")
|
||||
|
||||
return f"{this} APPLY({expr})"
|
||||
|
||||
def grant_sql(self, expression: exp.Grant) -> str:
|
||||
privileges_sql = self.expressions(expression, key="privileges", flat=True)
|
||||
|
||||
kind = self.sql(expression, "kind")
|
||||
kind = f" {kind}" if kind else ""
|
||||
|
||||
securable = self.sql(expression, "securable")
|
||||
securable = f" {securable}" if securable else ""
|
||||
|
||||
principals = self.expressions(expression, key="principals", flat=True)
|
||||
|
||||
grant_option = " WITH GRANT OPTION" if expression.args.get("grant_option") else ""
|
||||
|
||||
return f"GRANT {privileges_sql} ON{kind}{securable} TO {principals}{grant_option}"
|
||||
|
||||
def grantprivilege_sql(self, expression: exp.GrantPrivilege):
|
||||
this = self.sql(expression, "this")
|
||||
columns = self.expressions(expression, flat=True)
|
||||
columns = f"({columns})" if columns else ""
|
||||
|
||||
return f"{this}{columns}"
|
||||
|
||||
def grantprincipal_sql(self, expression: exp.GrantPrincipal):
|
||||
this = self.sql(expression, "this")
|
||||
|
||||
kind = self.sql(expression, "kind")
|
||||
kind = f"{kind} " if kind else ""
|
||||
|
||||
return f"{kind}{this}"
|
||||
|
||||
def columns_sql(self, expression: exp.Columns):
|
||||
func = self.function_fallback_sql(expression)
|
||||
if expression.args.get("unpack"):
|
||||
func = f"*{func}"
|
||||
|
||||
return func
|
||||
|
||||
def overlay_sql(self, expression: exp.Overlay):
|
||||
this = self.sql(expression, "this")
|
||||
expr = self.sql(expression, "expression")
|
||||
from_sql = self.sql(expression, "from")
|
||||
for_sql = self.sql(expression, "for")
|
||||
for_sql = f" FOR {for_sql}" if for_sql else ""
|
||||
|
||||
return f"OVERLAY({this} PLACING {expr} FROM {from_sql}{for_sql})"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue