summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/postgres.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/dialects/postgres.py')
-rw-r--r--sqlglot/dialects/postgres.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/sqlglot/dialects/postgres.py b/sqlglot/dialects/postgres.py
index d11cbd7..ef100b1 100644
--- a/sqlglot/dialects/postgres.py
+++ b/sqlglot/dialects/postgres.py
@@ -17,6 +17,7 @@ from sqlglot.dialects.dialect import (
no_tablesample_sql,
no_trycast_sql,
rename_func,
+ simplify_literal,
str_position_sql,
timestamptrunc_sql,
timestrtotime_sql,
@@ -39,16 +40,13 @@ DATE_DIFF_FACTOR = {
def _date_add_sql(kind: str) -> t.Callable[[generator.Generator, exp.DateAdd | exp.DateSub], str]:
def func(self: generator.Generator, expression: exp.DateAdd | exp.DateSub) -> str:
- from sqlglot.optimizer.simplify import simplify
-
this = self.sql(expression, "this")
unit = expression.args.get("unit")
- expression = simplify(expression.args["expression"])
+ expression = simplify_literal(expression.copy(), copy=False).expression
if not isinstance(expression, exp.Literal):
self.unsupported("Cannot add non literal")
- expression = expression.copy()
expression.args["is_string"] = True
return f"{this} {kind} {self.sql(exp.Interval(this=expression, unit=unit))}"