dabla commented on code in PR #39690:
URL: https://github.com/apache/airflow/pull/39690#discussion_r1605280393


##########
tests/providers/common/sql/hooks/test_dbapi.py:
##########
@@ -421,6 +421,56 @@ def test_get_uri_without_auth_and_empty_host(self):
         )
         assert self.db_hook.get_uri() == 
"conn-type://@:3306/schema?charset=utf-8"
 
+    def test_placeholder(self):
+        self.db_hook.get_connection = mock.MagicMock(
+            return_value=Connection(
+                conn_type="conn-type",
+                login=None,
+                password=None,
+                schema="schema",
+                port=3306,
+            )
+        )
+        assert self.db_hook.placeholder == "%s"
+
+        self.db_hook.log.warning.assert_not_called()
+
+    def test_placeholder_with_valid_placeholder_in_extra(self):
+        self.db_hook.get_connection = mock.MagicMock(
+            return_value=Connection(
+                conn_type="conn-type",
+                login=None,
+                password=None,
+                schema="schema",
+                port=3306,
+                extra=json.dumps({"placeholder": "?"}),
+            )
+        )
+        assert self.db_hook.placeholder == "?"
+
+        self.db_hook.log.warning.assert_not_called()
+
+    def test_placeholder_with_invalid_placeholder_in_extra(self):
+        self.db_hook.get_connection = mock.MagicMock(
+            return_value=Connection(
+                conn_type="conn-type",
+                login=None,
+                password=None,
+                schema="schema",
+                port=3306,
+                extra=json.dumps({"placeholder": "!"}),
+            )
+        )
+
+        assert self.db_hook.placeholder == "%s"
+
+        self.db_hook.log.warning.assert_called_once_with(
+            "Placeholder defined in Connection '%s' is not listed in 
'DEFAULT_SQL_PLACEHOLDERS' "
+            "and got ignored. Falling back to the default placeholder '%s'.",
+            "test_conn_id",
+            self.db_hook._placeholder,
+        )

Review Comment:
   Never mind found a solution



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to