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

kaxilnaik 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 a8c6451  Oracle Provider: Fix handling of bindvars with no parameters 
(#20720)
a8c6451 is described below

commit a8c6451e6196be64469a99247a4e75d6095b5470
Author: Malthe Borch <[email protected]>
AuthorDate: Fri Jan 7 13:13:43 2022 +0100

    Oracle Provider: Fix handling of bindvars with no parameters (#20720)
    
    This fixes a bug in the new callproc method where an exception will be 
raised when no parameters are provided – as in None.
---
 airflow/providers/oracle/hooks/oracle.py    |  3 +++
 tests/providers/oracle/hooks/test_oracle.py | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/airflow/providers/oracle/hooks/oracle.py 
b/airflow/providers/oracle/hooks/oracle.py
index b5dd453..d5f3a85 100644
--- a/airflow/providers/oracle/hooks/oracle.py
+++ b/airflow/providers/oracle/hooks/oracle.py
@@ -309,6 +309,9 @@ class OracleHook(DbApiHook):
         sql = f"BEGIN {identifier}({args}); END;"
 
         def handler(cursor):
+            if cursor.bindvars is None:
+                return
+
             if isinstance(cursor.bindvars, list):
                 return [v.getvalue() for v in cursor.bindvars]
 
diff --git a/tests/providers/oracle/hooks/test_oracle.py 
b/tests/providers/oracle/hooks/test_oracle.py
index 0f5c7df..3eae248 100644
--- a/tests/providers/oracle/hooks/test_oracle.py
+++ b/tests/providers/oracle/hooks/test_oracle.py
@@ -292,6 +292,18 @@ class TestOracleHook(unittest.TestCase):
         with pytest.raises(ValueError):
             self.db_hook.bulk_insert_rows('table', rows)
 
+    def test_callproc_none(self):
+        parameters = None
+
+        class bindvar(int):
+            def getvalue(self):
+                return self
+
+        self.cur.bindvars = None
+        result = self.db_hook.callproc('proc', True, parameters)
+        assert self.cur.execute.mock_calls == [mock.call('BEGIN proc(); END;')]
+        assert result == parameters
+
     def test_callproc_dict(self):
         parameters = {"a": 1, "b": 2, "c": 3}
 

Reply via email to