Adding upstream version 25.30.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c61927f460
commit
44a4f87ffd
69 changed files with 48139 additions and 46098 deletions
|
@ -237,6 +237,29 @@ def _unix_to_time_sql(self: Postgres.Generator, expression: exp.UnixToTime) -> s
|
|||
)
|
||||
|
||||
|
||||
def _build_levenshtein_less_equal(args: t.List) -> exp.Levenshtein:
|
||||
# Postgres has two signatures for levenshtein_less_equal function, but in both cases
|
||||
# max_dist is the last argument
|
||||
# levenshtein_less_equal(source, target, ins_cost, del_cost, sub_cost, max_d)
|
||||
# levenshtein_less_equal(source, target, max_d)
|
||||
max_dist = args.pop()
|
||||
|
||||
return exp.Levenshtein(
|
||||
this=seq_get(args, 0),
|
||||
expression=seq_get(args, 1),
|
||||
ins_cost=seq_get(args, 2),
|
||||
del_cost=seq_get(args, 3),
|
||||
sub_cost=seq_get(args, 4),
|
||||
max_dist=max_dist,
|
||||
)
|
||||
|
||||
|
||||
def _levenshtein_sql(self: Postgres.Generator, expression: exp.Levenshtein) -> str:
|
||||
name = "LEVENSHTEIN_LESS_EQUAL" if expression.args.get("max_dist") else "LEVENSHTEIN"
|
||||
|
||||
return rename_func(name)(self, expression)
|
||||
|
||||
|
||||
class Postgres(Dialect):
|
||||
INDEX_OFFSET = 1
|
||||
TYPED_DIVISION = True
|
||||
|
@ -365,6 +388,7 @@ class Postgres(Dialect):
|
|||
"SHA256": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(256)),
|
||||
"SHA384": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(384)),
|
||||
"SHA512": lambda args: exp.SHA2(this=seq_get(args, 0), length=exp.Literal.number(512)),
|
||||
"LEVENSHTEIN_LESS_EQUAL": _build_levenshtein_less_equal,
|
||||
}
|
||||
|
||||
FUNCTION_PARSERS = {
|
||||
|
@ -472,6 +496,7 @@ class Postgres(Dialect):
|
|||
COPY_HAS_INTO_KEYWORD = False
|
||||
ARRAY_CONCAT_IS_VAR_LEN = False
|
||||
SUPPORTS_MEDIAN = False
|
||||
ARRAY_SIZE_DIM_REQUIRED = True
|
||||
|
||||
SUPPORTED_JSON_PATH_PARTS = {
|
||||
exp.JSONPathKey,
|
||||
|
@ -495,7 +520,6 @@ class Postgres(Dialect):
|
|||
exp.AnyValue: any_value_to_max_sql,
|
||||
exp.ArrayConcat: lambda self, e: self.arrayconcat_sql(e, name="ARRAY_CAT"),
|
||||
exp.ArrayFilter: filter_array_using_unnest,
|
||||
exp.ArraySize: lambda self, e: self.func("ARRAY_LENGTH", e.this, e.expression or "1"),
|
||||
exp.BitwiseXor: lambda self, e: self.binary(e, "#"),
|
||||
exp.ColumnDef: transforms.preprocess([_auto_increment_to_serial, _serial_to_generated]),
|
||||
exp.CurrentDate: no_paren_current_date_sql,
|
||||
|
@ -568,6 +592,7 @@ class Postgres(Dialect):
|
|||
exp.Variance: rename_func("VAR_SAMP"),
|
||||
exp.Xor: bool_xor_sql,
|
||||
exp.UnixToTime: _unix_to_time_sql,
|
||||
exp.Levenshtein: _levenshtein_sql,
|
||||
}
|
||||
TRANSFORMS.pop(exp.CommentColumnConstraint)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue