Skip to content

Commit

Permalink
Fix handling of bindvars when no parameters are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
malthe committed Jan 6, 2022
1 parent 64cba10 commit 051b842
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions airflow/providers/oracle/hooks/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def callproc(
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]

Expand Down
12 changes: 12 additions & 0 deletions tests/providers/oracle/hooks/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ def test_bulk_insert_rows_no_rows(self):
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}

Expand Down

0 comments on commit 051b842

Please sign in to comment.