Merging upstream version 25.18.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
75ba8bde98
commit
f2390c2221
81 changed files with 34133 additions and 33517 deletions
|
@ -11,7 +11,7 @@ from sqlglot.generator import Generator
|
|||
from sqlglot.helper import AutoName, flatten, is_int, seq_get, subclasses
|
||||
from sqlglot.jsonpath import JSONPathTokenizer, parse as parse_json_path
|
||||
from sqlglot.parser import Parser
|
||||
from sqlglot.time import TIMEZONES, format_time
|
||||
from sqlglot.time import TIMEZONES, format_time, subsecond_precision
|
||||
from sqlglot.tokens import Token, Tokenizer, TokenType
|
||||
from sqlglot.trie import new_trie
|
||||
|
||||
|
@ -1243,13 +1243,24 @@ def right_to_substring_sql(self: Generator, expression: exp.Left) -> str:
|
|||
)
|
||||
|
||||
|
||||
def timestrtotime_sql(self: Generator, expression: exp.TimeStrToTime) -> str:
|
||||
datatype = (
|
||||
def timestrtotime_sql(
|
||||
self: Generator,
|
||||
expression: exp.TimeStrToTime,
|
||||
include_precision: bool = False,
|
||||
) -> str:
|
||||
datatype = exp.DataType.build(
|
||||
exp.DataType.Type.TIMESTAMPTZ
|
||||
if expression.args.get("zone")
|
||||
else exp.DataType.Type.TIMESTAMP
|
||||
)
|
||||
|
||||
if isinstance(expression.this, exp.Literal) and include_precision:
|
||||
precision = subsecond_precision(expression.this.name)
|
||||
if precision > 0:
|
||||
datatype = exp.DataType.build(
|
||||
datatype.this, expressions=[exp.DataTypeParam(this=exp.Literal.number(precision))]
|
||||
)
|
||||
|
||||
return self.sql(exp.cast(expression.this, datatype, dialect=self.dialect))
|
||||
|
||||
|
||||
|
@ -1295,7 +1306,7 @@ def trim_sql(self: Generator, expression: exp.Trim) -> str:
|
|||
collation = self.sql(expression, "collation")
|
||||
|
||||
# Use TRIM/LTRIM/RTRIM syntax if the expression isn't database-specific
|
||||
if not remove_chars and not collation:
|
||||
if not remove_chars:
|
||||
return self.trim_sql(expression)
|
||||
|
||||
trim_type = f"{trim_type} " if trim_type else ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue