Skip to content

Commit

Permalink
Add cache_ok flag to sqlalchemy TypeDecorators. (#24499)
Browse files Browse the repository at this point in the history
(cherry picked from commit d969473)
  • Loading branch information
jkinkead authored and potiuk committed Jul 5, 2022
1 parent 069a84c commit 679bd6a
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 @@ -58,6 +58,8 @@ class UtcDateTime(TypeDecorator):

impl = DateTime(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 @@ -101,6 +103,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 @@ -143,6 +147,8 @@ class Interval(TypeDecorator):

impl = Text

cache_ok = True

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

0 comments on commit 679bd6a

Please sign in to comment.