This is an automated email from the ASF dual-hosted git repository. isapego pushed a commit to branch ignite-13735 in repository https://gitbox.apache.org/repos/asf/ignite-python-thin-client.git
commit 4b60f30f73f6a7f3703c7fe4d5aa40339b6d1c25 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) --- pyignite/api/sql.py | 5 +---- tests/test_sql.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pyignite/api/sql.py b/pyignite/api/sql.py index f2f96fc..1a18496 100644 --- a/pyignite/api/sql.py +++ b/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/tests/test_sql.py b/tests/test_sql.py index d3c5f84..d983a20 100644 --- a/tests/test_sql.py +++ b/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)
