Skip to content

Commit 8129d10

Browse files
committed
Remove sv mods; update tests for distributed database
1 parent 1d3baa3 commit 8129d10

File tree

5 files changed

+43
-36
lines changed

5 files changed

+43
-36
lines changed

singlestoredb/clients/pymysqlsv/connections.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
SSCursor,
3030
DictCursor,
3131
SSDictCursor,
32-
SSCursorSV,
33-
SSDictCursorSV,
32+
# SSCursorSV,
33+
# SSDictCursorSV,
3434
)
3535
from .optionfile import Parser
3636
from .protocol import (
@@ -349,15 +349,15 @@ def _config(key, arg):
349349
self.resultclass = MySQLResult
350350

351351
# The C extension handles these types internally.
352-
if _pymysqlsv is not None and not self.pure_python:
353-
self.resultclass = MySQLResultSV
354-
if self.cursorclass is SSCursor:
355-
self.cursorclass = SSCursorSV
356-
elif self.cursorclass is DictCursor:
357-
self.output_type = 'dicts'
358-
elif self.cursorclass is SSDictCursor:
359-
self.cursorclass = SSDictCursorSV
360-
self.output_type = 'dicts'
352+
# if _pymysqlsv is not None and not self.pure_python:
353+
# self.resultclass = MySQLResultSV
354+
# if self.cursorclass is SSCursor:
355+
# self.cursorclass = SSCursorSV
356+
# elif self.cursorclass is DictCursor:
357+
# self.output_type = 'dicts'
358+
# elif self.cursorclass is SSDictCursor:
359+
# self.cursorclass = SSDictCursorSV
360+
# self.output_type = 'dicts'
361361

362362
self._result = None
363363
self._affected_rows = 0
@@ -584,15 +584,15 @@ def cursor(self, cursor=None):
584584
:type cursor: :py:class:`Cursor`, :py:class:`SSCursor`, :py:class:`DictCursor`, or :py:class:`SSDictCursor`.
585585
"""
586586
if cursor:
587-
if cursor is SSCursor:
588-
cursor = SSCursorSV
589-
elif cursor is DictCursor:
590-
# TODO: Passing in a cursor shouldn't affect connection output type
591-
self.output_type = 'dicts'
592-
elif cursor is SSDictCursor:
593-
cursor = SSDictCursorSV
594-
# TODO: Passing in a cursor shouldn't affect connection output type
595-
self.output_type = 'dicts'
587+
# if cursor is SSCursor:
588+
# cursor = SSCursorSV
589+
# elif cursor is DictCursor:
590+
# # TODO: Passing in a cursor shouldn't affect connection output type
591+
# self.output_type = 'dicts'
592+
# elif cursor is SSDictCursor:
593+
# cursor = SSDictCursorSV
594+
# # TODO: Passing in a cursor shouldn't affect connection output type
595+
# self.output_type = 'dicts'
596596
return cursor(self)
597597
return self.cursorclass(self)
598598

singlestoredb/clients/pymysqlsv/tests/test_DictCursor.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ def test_DictCursor(self):
7070
bob, r, 'fetch a 1 row result via iteration failed via DictCursor',
7171
)
7272
# get all 3 row via fetchall
73-
c.execute('SELECT * from dictcursor')
73+
c.execute('SELECT * from dictcursor ORDER BY name')
7474
r = c.fetchall()
75-
self.assertEqual([bob, jim, fred], r, 'fetchall failed via DictCursor')
75+
self.assertEqual([bob, fred, jim], r, 'fetchall failed via DictCursor')
7676
# same test again but do a list comprehension
77-
c.execute('SELECT * from dictcursor')
77+
c.execute('SELECT * from dictcursor ORDER BY name')
7878
r = list(c)
79-
self.assertEqual([bob, jim, fred], r, 'DictCursor should be iterable')
79+
self.assertEqual([bob, fred, jim], r, 'DictCursor should be iterable')
8080
# get all 2 row via fetchmany
81-
c.execute('SELECT * from dictcursor')
81+
c.execute('SELECT * from dictcursor ORDER BY name')
8282
r = c.fetchmany(2)
83-
self.assertEqual([bob, jim], r, 'fetchmany failed via DictCursor')
83+
self.assertEqual([bob, fred], r, 'fetchmany failed via DictCursor')
8484
self._ensure_cursor_expired(c)
8585

8686
def test_custom_dict(self):
@@ -101,17 +101,17 @@ class MyDictCursor(self.cursor_type):
101101
self.assertEqual(bob, r, 'fetchone() returns MyDictCursor')
102102
self._ensure_cursor_expired(cur)
103103

104-
cur.execute('SELECT * FROM dictcursor')
104+
cur.execute('SELECT * FROM dictcursor ORDER BY name')
105105
r = cur.fetchall()
106-
self.assertEqual([bob, jim, fred], r, 'fetchall failed via MyDictCursor')
106+
self.assertEqual([bob, fred, jim], r, 'fetchall failed via MyDictCursor')
107107

108-
cur.execute('SELECT * FROM dictcursor')
108+
cur.execute('SELECT * FROM dictcursor ORDER BY name')
109109
r = list(cur)
110-
self.assertEqual([bob, jim, fred], r, 'list failed via MyDictCursor')
110+
self.assertEqual([bob, fred, jim], r, 'list failed via MyDictCursor')
111111

112-
cur.execute('SELECT * FROM dictcursor')
112+
cur.execute('SELECT * FROM dictcursor ORDER BY name')
113113
r = cur.fetchmany(2)
114-
self.assertEqual([bob, jim], r, 'list failed via MyDictCursor')
114+
self.assertEqual([bob, fred], r, 'list failed via MyDictCursor')
115115
self._ensure_cursor_expired(cur)
116116

117117

singlestoredb/clients/pymysqlsv/tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_datatypes(self):
7575
'select l from test_datatypes where i in %s order by i', (seq,),
7676
)
7777
r = c.fetchall()
78-
self.assertEqual([(4,), (8,)], r)
78+
self.assertEqual(((4,), (8,)), r)
7979
c.execute('delete from test_datatypes')
8080

8181
finally:

singlestoredb/clients/pymysqlsv/tests/test_issues.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ def test_issue_321(self):
409409
'insert into issue321 (value_1, value_2) '
410410
'values (%(value_1)s, %(value_2)s)'
411411
)
412-
sql_select = 'select * from issue321 where ' 'value_1 in %s and value_2=%s'
412+
sql_select = 'select * from issue321 ' + \
413+
'where value_1 in %s and value_2=%s order by value_1'
413414
data = [
414415
[('a',), '\u0430'],
415416
[['b'], '\u0430'],

singlestoredb/clients/pymysqlsv/tests/thirdparty/test_MySQLdb/capabilities.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def check_data_integrity(self, columndefs, generator):
9696
self.cursor.executemany(insert_statement, data)
9797
self.connection.commit()
9898
# verify
99-
self.cursor.execute('select * from %s' % self.table)
99+
self.cursor.execute(
100+
'select * from %s ORDER BY %s' %
101+
(self.table, columndefs[0].split()[0]),
102+
)
100103
l = self.cursor.fetchall()
101104
if self.debug:
102105
print(l)
@@ -129,7 +132,10 @@ def generator(row, col):
129132
self.cursor.executemany(insert_statement, data)
130133
# verify
131134
self.connection.commit()
132-
self.cursor.execute('select * from %s' % self.table)
135+
self.cursor.execute(
136+
'select * from %s ORDER BY %s' %
137+
(self.table, columndefs[0].split()[0]),
138+
)
133139
l = self.cursor.fetchall()
134140
self.assertEqual(len(l), self.rows)
135141
for i in range(self.rows):

0 commit comments

Comments
 (0)