Fix datetime fn mysql (#9825)

* fix: mysql datetime function

* empty commit to re-run tests
This commit is contained in:
Teddy 2023-01-20 15:33:55 +01:00 committed by GitHub
parent cdd2bc66db
commit 7d0eeeb802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,6 +104,16 @@ def _(elements, compiler, **kwargs):
)
@compiles(DatetimeAddFn, Dialects.MySQL)
def _(elements, compiler, **kwargs):
"""MySQL date and datetime function"""
interval = elements.clauses.clauses[0].value
interval_unit = compiler.process(elements.clauses.clauses[1], **kwargs)
return (
f"CAST(CURRENT_TIMESTAMP - interval '{interval}' {interval_unit} AS DATETIME)"
)
@compiles(DatetimeAddFn, Dialects.BigQuery)
def _(elements, compiler, **kwargs):
"""generic date and datetime function"""