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

alexpl pushed a commit to branch ignite-2.9
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 8531c4697f11fb0332a3599d723122f520ecb4a3
Author: Nikolay <[email protected]>
AuthorDate: Tue Sep 1 12:09:42 2020 +0300

    IGNITE-12809 Python thin client - Fix wrong order of the SQL query result 
(#8203)
    
    (cherry picked from commit 38025ee4167f05eaa2d6a2c5c2ab70c83a462cfc)
---
 .gitignore                                   |  6 ++++++
 modules/platforms/python/pyignite/api/sql.py |  5 +----
 modules/platforms/python/tests/test_sql.py   | 30 ++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index dea16dd..ef98e66 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,3 +80,9 @@ packages
 
 #NodeJs files
 /modules/platforms/nodejs/node_modules
+
+#Python temp files
+**/.eggs
+**/venv
+**/.pytest_cache
+**/pyignite.egg-info
diff --git a/modules/platforms/python/pyignite/api/sql.py 
b/modules/platforms/python/pyignite/api/sql.py
index f2f96fc..1a18496 100644
--- a/modules/platforms/python/pyignite/api/sql.py
+++ b/modules/platforms/python/pyignite/api/sql.py
@@ -441,10 +441,7 @@ def sql_fields_cursor_get_page(
         'more': value['more']
     }
     for row_dict in value['data']:
-        row = []
-        for field_key in sorted(row_dict.keys()):
-            row.append(row_dict[field_key])
-        result.value['data'].append(row)
+        result.value['data'].append(list(row_dict.values()))
     return result
 
 
diff --git a/modules/platforms/python/tests/test_sql.py 
b/modules/platforms/python/tests/test_sql.py
index d3c5f84..d983a20 100644
--- a/modules/platforms/python/tests/test_sql.py
+++ b/modules/platforms/python/tests/test_sql.py
@@ -152,3 +152,33 @@ def test_sql_fields(client):
     # repeat cleanup
     result = sql_fields(client, 'PUBLIC', drop_query, page_size)
     assert result.status == 0
+
+
+def test_long_multipage_query(client):
+    """
+    The test creates a table with 13 columns (id and 12 enumerated columns)
+    and 20 records with id in range from 1 to 20. Values of enumerated columns
+    are = column number * id.
+
+    The goal is to ensure that all the values are selected in a right order.
+    """
+
+    fields = ["id", "abc", "ghi", "def", "jkl", "prs", "mno", "tuw", "zyz", 
"abc1", "def1", "jkl1", "prs1"]
+
+    client.sql('DROP TABLE LongMultipageQuery IF EXISTS')
+
+    client.sql("CREATE TABLE LongMultiPageQuery (%s, %s)" % \
+               (fields[0] + " INT(11) PRIMARY KEY", ",".join(map(lambda f: f + 
" INT(11)", fields[1:]))))
+
+    for id in range(1, 21):
+        client.sql(
+            "INSERT INTO LongMultipageQuery (%s) VALUES (%s)" % 
(",".join(fields), ",".join("?" * len(fields))),
+            query_args=[id] + list(i * id for i in range(1, len(fields))))
+
+    result = client.sql('SELECT * FROM LongMultipageQuery', page_size=1)
+    for page in result:
+        assert len(page) == len(fields)
+        for field_number, value in enumerate(page[1:], start=1):
+            assert value == field_number * page[0]
+
+    client.sql(drop_query)

Reply via email to