Skip to content

Commit d075a43

Browse files
isapegonizhikov
andauthored
GG-32661 [IGNITE-12809] Fix wrong order of the SQL query result (#17)
(cherry picked from commit 4b60f30) Co-authored-by: Nikolay <nizhikov@apache.org>
1 parent f8b6a87 commit d075a43

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

pygridgain/api/sql.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,7 @@ def sql_fields_cursor_get_page(
429429
'more': value['more']
430430
}
431431
for row_dict in value['data']:
432-
row = []
433-
for field_key in sorted(row_dict.keys()):
434-
row.append(row_dict[field_key])
435-
result.value['data'].append(row)
432+
result.value['data'].append(list(row_dict.values()))
436433
return result
437434

438435

tests/test_sql.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,33 @@ def test_sql_fields(client):
156156
# repeat cleanup
157157
result = sql_fields(conn, 'PUBLIC', drop_query, page_size)
158158
assert result.status == 0
159+
160+
161+
def test_long_multipage_query(client):
162+
"""
163+
The test creates a table with 13 columns (id and 12 enumerated columns)
164+
and 20 records with id in range from 1 to 20. Values of enumerated columns
165+
are = column number * id.
166+
167+
The goal is to ensure that all the values are selected in a right order.
168+
"""
169+
170+
fields = ["id", "abc", "ghi", "def", "jkl", "prs", "mno", "tuw", "zyz", "abc1", "def1", "jkl1", "prs1"]
171+
172+
client.sql('DROP TABLE LongMultipageQuery IF EXISTS')
173+
174+
client.sql("CREATE TABLE LongMultiPageQuery (%s, %s)" % \
175+
(fields[0] + " INT(11) PRIMARY KEY", ",".join(map(lambda f: f + " INT(11)", fields[1:]))))
176+
177+
for id in range(1, 21):
178+
client.sql(
179+
"INSERT INTO LongMultipageQuery (%s) VALUES (%s)" % (",".join(fields), ",".join("?" * len(fields))),
180+
query_args=[id] + list(i * id for i in range(1, len(fields))))
181+
182+
result = client.sql('SELECT * FROM LongMultipageQuery', page_size=1)
183+
for page in result:
184+
assert len(page) == len(fields)
185+
for field_number, value in enumerate(page[1:], start=1):
186+
assert value == field_number * page[0]
187+
188+
client.sql(drop_query)

0 commit comments

Comments
 (0)