From 3e8449fbcfa97c267b58447d1eb72b17c5fda76b Mon Sep 17 00:00:00 2001 From: Benjamin Laumann <44522777+Briimbo@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:40:19 +0100 Subject: [PATCH] Fix rowcount logging in exasol provider (#44022) (#45760) --- providers/src/airflow/providers/exasol/hooks/exasol.py | 2 +- providers/tests/exasol/hooks/test_exasol.py | 2 +- providers/tests/exasol/hooks/test_sql.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/providers/src/airflow/providers/exasol/hooks/exasol.py b/providers/src/airflow/providers/exasol/hooks/exasol.py index ad3362e9115ee..69c51ab4c8eb2 100644 --- a/providers/src/airflow/providers/exasol/hooks/exasol.py +++ b/providers/src/airflow/providers/exasol/hooks/exasol.py @@ -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): diff --git a/providers/tests/exasol/hooks/test_exasol.py b/providers/tests/exasol/hooks/test_exasol.py index 1c58431ea693f..9882622aef5a4 100644 --- a/providers/tests/exasol/hooks/test_exasol.py +++ b/providers/tests/exasol/hooks/test_exasol.py @@ -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 diff --git a/providers/tests/exasol/hooks/test_sql.py b/providers/tests/exasol/hooks/test_sql.py index 4864c83790297..4e57ebe4b6168 100644 --- a/providers/tests/exasol/hooks/test_sql.py +++ b/providers/tests/exasol/hooks/test_sql.py @@ -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] @@ -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"