You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/08/21 14:13:23 UTC

[superset] branch 3.0 updated (6a92ed9bd9 -> 34bc86a484)

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

michaelsmolina pushed a change to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git


 discard 6a92ed9bd9 fix(mssql): avoid trying to return a resultset for DML queries with not resultset (#24999)
     new 34bc86a484 fix(mssql): avoid trying to return a resultset for DML queries with not resultset (#24999)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (6a92ed9bd9)
            \
             N -- N -- N   refs/heads/3.0 (34bc86a484)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 superset/sql_parse.py | 1 +
 1 file changed, 1 insertion(+)


[superset] 01/01: fix(mssql): avoid trying to return a resultset for DML queries with not resultset (#24999)

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 34bc86a484feea629376c4f6b92d5b45d87d995a
Author: Yuval Moshe <53...@users.noreply.github.com>
AuthorDate: Mon Aug 21 14:33:26 2023 +0300

    fix(mssql): avoid trying to return a resultset for DML queries with not resultset (#24999)
    
    (cherry picked from commit 66eabc253faf2c27db5aaf5283ab2e00fedaa817)
---
 superset/db_engine_specs/mssql.py              |  2 ++
 superset/sql_parse.py                          |  1 +
 tests/unit_tests/db_engine_specs/test_mssql.py | 11 ++++++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/superset/db_engine_specs/mssql.py b/superset/db_engine_specs/mssql.py
index 5d29d36ba8..d5cc86c859 100644
--- a/superset/db_engine_specs/mssql.py
+++ b/superset/db_engine_specs/mssql.py
@@ -141,6 +141,8 @@ class MssqlEngineSpec(BaseEngineSpec):
     def fetch_data(
         cls, cursor: Any, limit: Optional[int] = None
     ) -> list[tuple[Any, ...]]:
+        if not cursor.description:
+            return []
         data = super().fetch_data(cursor, limit)
         # Lists of `pyodbc.Row` need to be unpacked further
         return cls.pyodbc_rows_to_tuples(data)
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index f917be80ab..9a74b137e0 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -217,6 +217,7 @@ class ParsedQuery:
     def limit(self) -> Optional[int]:
         return self._limit
 
+    # pylint: disable=no-self-use
     def _get_cte_tables(self, parsed: dict[str, Any]) -> list[dict[str, Any]]:
         if "with" not in parsed:
             return []
diff --git a/tests/unit_tests/db_engine_specs/test_mssql.py b/tests/unit_tests/db_engine_specs/test_mssql.py
index 8149e60cd8..56ff887922 100644
--- a/tests/unit_tests/db_engine_specs/test_mssql.py
+++ b/tests/unit_tests/db_engine_specs/test_mssql.py
@@ -157,6 +157,14 @@ def test_extract_error_message() -> None:
     assert expected_message == error_message
 
 
+def test_fetch_data_no_description() -> None:
+    from superset.db_engine_specs.mssql import MssqlEngineSpec
+
+    cursor = mock.MagicMock()
+    cursor.description = []
+    assert MssqlEngineSpec.fetch_data(cursor) == []
+
+
 def test_fetch_data() -> None:
     from superset.db_engine_specs.base import BaseEngineSpec
     from superset.db_engine_specs.mssql import MssqlEngineSpec
@@ -166,9 +174,10 @@ def test_fetch_data() -> None:
         "pyodbc_rows_to_tuples",
         return_value="converted",
     ) as mock_pyodbc_rows_to_tuples:
+        cursor = mock.MagicMock()
         data = [(1, "foo")]
         with mock.patch.object(BaseEngineSpec, "fetch_data", return_value=data):
-            result = MssqlEngineSpec.fetch_data(None, 0)
+            result = MssqlEngineSpec.fetch_data(cursor, 0)
             mock_pyodbc_rows_to_tuples.assert_called_once_with(data)
             assert result == "converted"