You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2024/10/04 23:53:58 UTC

(airflow) branch main updated: feat(providers/common/sql): add warning to connection setter (#42736)

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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5973c9cce1 feat(providers/common/sql): add warning to connection setter (#42736)
5973c9cce1 is described below

commit 5973c9cce1a51042298e198df2097a94fd48ac5d
Author: Wei Lee <we...@gmail.com>
AuthorDate: Sat Oct 5 08:53:50 2024 +0900

    feat(providers/common/sql): add warning to connection setter (#42736)
---
 airflow/providers/common/sql/hooks/sql.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/airflow/providers/common/sql/hooks/sql.py b/airflow/providers/common/sql/hooks/sql.py
index c0a3ed5f9a..dfa8c6fc72 100644
--- a/airflow/providers/common/sql/hooks/sql.py
+++ b/airflow/providers/common/sql/hooks/sql.py
@@ -212,14 +212,15 @@ class DbApiHook(BaseHook):
 
     @connection.setter
     def connection(self, value: Any) -> None:
-        # This setter is for backward compatibility and should not be used.
-        # Since the introduction of connection property, the providers listed below
-        # breaks due to assigning value to self.connection
-        #
-        # apache-airflow-providers-mysql<5.7.1
-        # apache-airflow-providers-elasticsearch<5.5.1
-        # apache-airflow-providers-postgres<5.13.0
-        pass
+        if value != self.connection:
+            self.log.warning(
+                "This setter is for backward compatibility and should not be used.\n"
+                "Since the introduction of connection property, the providers listed below "
+                "breaks due to assigning value to self.connection in their __init__ method.\n"
+                "* apache-airflow-providers-mysql<5.7.1\n"
+                "* apache-airflow-providers-elasticsearch<5.5.1\n"
+                "* apache-airflow-providers-postgres<5.13.0"
+            )
 
     @property
     def connection_extra(self) -> dict: