Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of Oracle bindvars in stored procedure call when parameters are not provided #20720

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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