Skip to content

Commit

Permalink
Fix rowcount logging in exasol provider (apache#44022) (apache#45760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Briimbo authored Jan 18, 2025
1 parent 2b1b399 commit 3e8449f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion providers/src/airflow/providers/exasol/hooks/exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def run(
else:
results.append(result)
self.descriptions.append(self.get_description(exa_statement))
self.log.info("Rows affected: %s", exa_statement.rowcount)
self.log.info("Rows affected: %s", exa_statement.rowcount())

# If autocommit was set to False or db does not support autocommit, we do a manual commit.
if not self.get_autocommit(conn):
Expand Down
2 changes: 1 addition & 1 deletion providers/tests/exasol/hooks/test_exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_get_conn_extra_args(self, mock_pyexasol):

class TestExasolHook:
def setup_method(self):
self.cur = mock.MagicMock(rowcount=0)
self.cur = mock.MagicMock(rowcount=lambda: 0)
self.conn = mock.MagicMock()
self.conn.execute.return_value = self.cur
conn = self.conn
Expand Down
4 changes: 2 additions & 2 deletions providers/tests/exasol/hooks/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_query(
cursors = []
for index in range(len(cursor_descriptions)):
cur = mock.MagicMock(
rowcount=len(cursor_results[index]),
rowcount=lambda: len(cursor_results[index]),
)
cur.columns.return_value = get_columns(cursor_descriptions[index])
cur.fetchall.return_value = cursor_results[index]
Expand All @@ -287,7 +287,7 @@ def test_query(
)
def test_no_query(empty_statement):
dbapi_hook = ExasolHookForTests()
dbapi_hook.get_conn.return_value.cursor.rowcount = 0
dbapi_hook.get_conn.return_value.cursor.rowcount = lambda: 0
with pytest.raises(ValueError) as err:
dbapi_hook.run(sql=empty_statement)
assert err.value.args[0] == "List of SQL statements is empty"

0 comments on commit 3e8449f

Please sign in to comment.