Merging upstream version 26.8.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
d551ab0954
commit
010433ad9a
61 changed files with 43883 additions and 41898 deletions
|
@ -3,6 +3,8 @@ from __future__ import annotations
|
|||
import importlib
|
||||
import logging
|
||||
import typing as t
|
||||
import sys
|
||||
|
||||
from enum import Enum, auto
|
||||
from functools import reduce
|
||||
|
||||
|
@ -103,6 +105,20 @@ class NormalizationStrategy(str, AutoName):
|
|||
"""Always case-insensitive, regardless of quotes."""
|
||||
|
||||
|
||||
class Version(int):
|
||||
def __new__(cls, version_str: t.Optional[str], *args, **kwargs):
|
||||
if version_str:
|
||||
parts = version_str.split(".")
|
||||
parts.extend(["0"] * (3 - len(parts)))
|
||||
v = int("".join([p.zfill(3) for p in parts]))
|
||||
else:
|
||||
# No version defined means we should support the latest engine semantics, so
|
||||
# the comparison to any specific version should yield that latest is greater
|
||||
v = sys.maxsize
|
||||
|
||||
return super(Version, cls).__new__(cls, v)
|
||||
|
||||
|
||||
class _Dialect(type):
|
||||
_classes: t.Dict[str, t.Type[Dialect]] = {}
|
||||
|
||||
|
@ -453,6 +469,9 @@ class Dialect(metaclass=_Dialect):
|
|||
NUMBERS_CAN_BE_UNDERSCORE_SEPARATED = False
|
||||
"""Whether number literals can include underscores for better readability"""
|
||||
|
||||
HEX_STRING_IS_INTEGER_TYPE: bool = False
|
||||
"""Whether hex strings such as x'CC' evaluate to integer or binary/blob type"""
|
||||
|
||||
REGEXP_EXTRACT_DEFAULT_GROUP = 0
|
||||
"""The default value for the capturing group."""
|
||||
|
||||
|
@ -1002,6 +1021,10 @@ class Dialect(metaclass=_Dialect):
|
|||
def generator(self, **opts) -> Generator:
|
||||
return self.generator_class(dialect=self, **opts)
|
||||
|
||||
@property
|
||||
def version(self) -> Version:
|
||||
return Version(self.settings.get("version", None))
|
||||
|
||||
|
||||
DialectType = t.Union[str, Dialect, t.Type[Dialect], None]
|
||||
|
||||
|
@ -1384,9 +1407,9 @@ def count_if_to_sum(self: Generator, expression: exp.CountIf) -> str:
|
|||
return self.func("sum", exp.func("if", cond, 1, 0))
|
||||
|
||||
|
||||
def trim_sql(self: Generator, expression: exp.Trim) -> str:
|
||||
def trim_sql(self: Generator, expression: exp.Trim, default_trim_type: str = "") -> str:
|
||||
target = self.sql(expression, "this")
|
||||
trim_type = self.sql(expression, "position")
|
||||
trim_type = self.sql(expression, "position") or default_trim_type
|
||||
remove_chars = self.sql(expression, "expression")
|
||||
collation = self.sql(expression, "collation")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue