Skip to content

Commit

Permalink
Add cache_ok flag to sqlalchemy TypeDecorators. (apache#24499)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkinkead committed Jul 5, 2022
1 parent cc6a44b commit d969473
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions airflow/utils/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class UtcDateTime(TypeDecorator):

impl = TIMESTAMP(timezone=True)

cache_ok = True

def process_bind_param(self, value, dialect):
if value is not None:
if not isinstance(value, datetime.datetime):
Expand Down Expand Up @@ -110,6 +112,8 @@ class ExtendedJSON(TypeDecorator):

impl = Text

cache_ok = True

def db_supports_json(self):
"""Checks if the database supports JSON (i.e. is NOT MSSQL)"""
return not conf.get("database", "sql_alchemy_conn").startswith("mssql")
Expand Down Expand Up @@ -212,6 +216,8 @@ class Interval(TypeDecorator):

impl = Text

cache_ok = True

attr_keys = {
datetime.timedelta: ('days', 'seconds', 'microseconds'),
relativedelta.relativedelta: (
Expand Down

0 comments on commit d969473

Please sign in to comment.