Skip to content

Commit e705d63

Browse files
committed
Fix CONPY-283: Incorrect result format after cursor.scroll()
Since unsigned long is 32-bit under windows, row_number must be defined as uint64_t, since we assign 64-bit values directly from python code.
1 parent d672551 commit e705d63

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

include/mariadb_python.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ typedef struct {
290290
uint32_t field_count;
291291
int64_t row_count;
292292
uint64_t lastrow_id;
293-
unsigned long row_number;
293+
uint64_t row_number;
294294
enum enum_result_format result_format;
295295
uint8_t is_prepared;
296296
char is_buffered;

testing/test/integration/test_cursor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ def test_multiple_close(self):
4040
cursor.close()
4141
del cursor
4242

43+
def test_conpy283(self):
44+
conn= create_connection()
45+
cursor= conn.cursor(dictionary=True)
46+
self.assertEqual(cursor._resulttype, 2)
47+
cursor.execute("select 1 as A union SELECT 2 as A")
48+
row= cursor.fetchone()
49+
self.assertEqual(row, {'A' : 1})
50+
self.assertEqual(cursor._resulttype, 2)
51+
cursor.scroll(-1)
52+
self.assertEqual(cursor._resulttype, 2)
53+
row= cursor.fetchone()
54+
self.assertEqual(row, {'A' : 1})
55+
row= cursor.fetchone()
56+
self.assertEqual(row, {'A' : 2})
57+
self.assertEqual(cursor._resulttype, 2)
58+
cursor.close()
59+
conn.close()
60+
4361
def test_date(self):
4462
v = self.connection.server_version
4563
i = self.connection.server_info.lower()

0 commit comments

Comments
 (0)