You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/07/06 10:48:56 UTC

[airflow] 01/03: Fix the implementation of UtcDateTime for MsSQL

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 89f96a8830633f21f062e65d2836fde90416ff70
Author: Jarek Potiuk <ja...@polidea.com>
AuthorDate: Tue Jul 5 22:40:23 2022 +0000

    Fix the implementation of UtcDateTime for MsSQL
---
 airflow/utils/sqlalchemy.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/airflow/utils/sqlalchemy.py b/airflow/utils/sqlalchemy.py
index b10af0a74d..c94b4100dd 100644
--- a/airflow/utils/sqlalchemy.py
+++ b/airflow/utils/sqlalchemy.py
@@ -24,6 +24,7 @@ from typing import Any, Dict, Iterable, Tuple
 import pendulum
 from dateutil import relativedelta
 from sqlalchemy import and_, event, false, nullsfirst, or_, tuple_
+from sqlalchemy.dialects import mssql
 from sqlalchemy.exc import OperationalError
 from sqlalchemy.orm.session import Session
 from sqlalchemy.sql import ColumnElement
@@ -94,6 +95,11 @@ class UtcDateTime(TypeDecorator):
 
         return value
 
+    def load_dialect_impl(self, dialect):
+        if dialect.name == 'mssql':
+            return mssql.DATETIME2(precision=6)
+        return super().load_dialect_impl(dialect)
+
 
 class ExtendedJSON(TypeDecorator):
     """