Merging upstream version 20.11.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
1bce3d0317
commit
e71ccc03da
141 changed files with 66644 additions and 54334 deletions
|
@ -77,6 +77,7 @@ class Generator:
|
|||
exp.ExecuteAsProperty: lambda self, e: self.naked_property(e),
|
||||
exp.ExternalProperty: lambda self, e: "EXTERNAL",
|
||||
exp.HeapProperty: lambda self, e: "HEAP",
|
||||
exp.InheritsProperty: lambda self, e: f"INHERITS ({self.expressions(e, flat=True)})",
|
||||
exp.InlineLengthColumnConstraint: lambda self, e: f"INLINE LENGTH {self.sql(e, 'this')}",
|
||||
exp.InputModelProperty: lambda self, e: f"INPUT{self.sql(e, 'this')}",
|
||||
exp.IntervalSpan: lambda self, e: f"{self.sql(e, 'this')} TO {self.sql(e, 'expression')}",
|
||||
|
@ -96,6 +97,7 @@ class Generator:
|
|||
exp.ReturnsProperty: lambda self, e: self.naked_property(e),
|
||||
exp.SampleProperty: lambda self, e: f"SAMPLE BY {self.sql(e, 'this')}",
|
||||
exp.SetProperty: lambda self, e: f"{'MULTI' if e.args.get('multi') else ''}SET",
|
||||
exp.SetConfigProperty: lambda self, e: self.sql(e, "this"),
|
||||
exp.SettingsProperty: lambda self, e: f"SETTINGS{self.seg('')}{(self.expressions(e))}",
|
||||
exp.SqlReadWriteProperty: lambda self, e: e.name,
|
||||
exp.SqlSecurityProperty: lambda self, e: f"SQL SECURITY {'DEFINER' if e.args.get('definer') else 'INVOKER'}",
|
||||
|
@ -323,6 +325,7 @@ class Generator:
|
|||
exp.FileFormatProperty: exp.Properties.Location.POST_WITH,
|
||||
exp.FreespaceProperty: exp.Properties.Location.POST_NAME,
|
||||
exp.HeapProperty: exp.Properties.Location.POST_WITH,
|
||||
exp.InheritsProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.InputModelProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.IsolatedLoadingProperty: exp.Properties.Location.POST_NAME,
|
||||
exp.JournalProperty: exp.Properties.Location.POST_NAME,
|
||||
|
@ -353,6 +356,7 @@ class Generator:
|
|||
exp.Set: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.SettingsProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.SetProperty: exp.Properties.Location.POST_CREATE,
|
||||
exp.SetConfigProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.SortKeyProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.SqlReadWriteProperty: exp.Properties.Location.POST_SCHEMA,
|
||||
exp.SqlSecurityProperty: exp.Properties.Location.POST_CREATE,
|
||||
|
@ -568,9 +572,11 @@ class Generator:
|
|||
|
||||
def wrap(self, expression: exp.Expression | str) -> str:
|
||||
this_sql = self.indent(
|
||||
self.sql(expression)
|
||||
if isinstance(expression, (exp.Select, exp.Union))
|
||||
else self.sql(expression, "this"),
|
||||
(
|
||||
self.sql(expression)
|
||||
if isinstance(expression, (exp.Select, exp.Union))
|
||||
else self.sql(expression, "this")
|
||||
),
|
||||
level=1,
|
||||
pad=0,
|
||||
)
|
||||
|
@ -605,9 +611,11 @@ class Generator:
|
|||
lines = sql.split("\n")
|
||||
|
||||
return "\n".join(
|
||||
line
|
||||
if (skip_first and i == 0) or (skip_last and i == len(lines) - 1)
|
||||
else f"{' ' * (level * self._indent + pad)}{line}"
|
||||
(
|
||||
line
|
||||
if (skip_first and i == 0) or (skip_last and i == len(lines) - 1)
|
||||
else f"{' ' * (level * self._indent + pad)}{line}"
|
||||
)
|
||||
for i, line in enumerate(lines)
|
||||
)
|
||||
|
||||
|
@ -775,7 +783,7 @@ class Generator:
|
|||
def generatedasrowcolumnconstraint_sql(
|
||||
self, expression: exp.GeneratedAsRowColumnConstraint
|
||||
) -> str:
|
||||
start = "START" if expression.args["start"] else "END"
|
||||
start = "START" if expression.args.get("start") else "END"
|
||||
hidden = " HIDDEN" if expression.args.get("hidden") else ""
|
||||
return f"GENERATED ALWAYS AS ROW {start}{hidden}"
|
||||
|
||||
|
@ -1111,7 +1119,10 @@ class Generator:
|
|||
partition_by = self.expressions(expression, key="partition_by", flat=True)
|
||||
partition_by = f" PARTITION BY {partition_by}" if partition_by else ""
|
||||
where = self.sql(expression, "where")
|
||||
return f"{unique}{primary}{amp}{index}{name}{table}{using}{columns}{partition_by}{where}"
|
||||
include = self.expressions(expression, key="include", flat=True)
|
||||
if include:
|
||||
include = f" INCLUDE ({include})"
|
||||
return f"{unique}{primary}{amp}{index}{name}{table}{using}{columns}{include}{partition_by}{where}"
|
||||
|
||||
def identifier_sql(self, expression: exp.Identifier) -> str:
|
||||
text = expression.name
|
||||
|
@ -2017,9 +2028,11 @@ class Generator:
|
|||
def after_having_modifiers(self, expression: exp.Expression) -> t.List[str]:
|
||||
return [
|
||||
self.sql(expression, "qualify"),
|
||||
self.seg("WINDOW ") + self.expressions(expression, key="windows", flat=True)
|
||||
if expression.args.get("windows")
|
||||
else "",
|
||||
(
|
||||
self.seg("WINDOW ") + self.expressions(expression, key="windows", flat=True)
|
||||
if expression.args.get("windows")
|
||||
else ""
|
||||
),
|
||||
self.sql(expression, "distribute"),
|
||||
self.sql(expression, "sort"),
|
||||
self.sql(expression, "cluster"),
|
||||
|
@ -2552,6 +2565,11 @@ class Generator:
|
|||
zone = self.sql(expression, "zone")
|
||||
return f"{this} AT TIME ZONE {zone}"
|
||||
|
||||
def fromtimezone_sql(self, expression: exp.FromTimeZone) -> str:
|
||||
this = self.sql(expression, "this")
|
||||
zone = self.sql(expression, "zone")
|
||||
return f"{this} AT TIME ZONE {zone} AT TIME ZONE 'UTC'"
|
||||
|
||||
def add_sql(self, expression: exp.Add) -> str:
|
||||
return self.binary(expression, "+")
|
||||
|
||||
|
@ -2669,6 +2687,10 @@ class Generator:
|
|||
if default:
|
||||
return f"ALTER COLUMN {this} SET DEFAULT {default}"
|
||||
|
||||
comment = self.sql(expression, "comment")
|
||||
if comment:
|
||||
return f"ALTER COLUMN {this} COMMENT {comment}"
|
||||
|
||||
if not expression.args.get("drop"):
|
||||
self.unsupported("Unsupported ALTER COLUMN syntax")
|
||||
|
||||
|
@ -2683,6 +2705,12 @@ class Generator:
|
|||
this = self.sql(expression, "this")
|
||||
return f"RENAME TO {this}"
|
||||
|
||||
def renamecolumn_sql(self, expression: exp.RenameColumn) -> str:
|
||||
exists = " IF EXISTS" if expression.args.get("exists") else ""
|
||||
old_column = self.sql(expression, "this")
|
||||
new_column = self.sql(expression, "to")
|
||||
return f"RENAME COLUMN{exists} {old_column} TO {new_column}"
|
||||
|
||||
def altertable_sql(self, expression: exp.AlterTable) -> str:
|
||||
actions = expression.args["actions"]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue