File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Original file line number Diff line number Diff line change @@ -1021,10 +1021,13 @@ def _execute_command(self, command, sql):
1021
1021
1022
1022
# If the last query was unbuffered, make sure it finishes before
1023
1023
# sending new commands
1024
- if self ._result is not None and self ._result .unbuffered_active :
1025
- warnings .warn ("Previous unbuffered result was left incomplete" )
1026
- self ._result ._finish_unbuffered_query ()
1027
- self ._result = None
1024
+ if self ._result is not None :
1025
+ if self ._result .unbuffered_active :
1026
+ warnings .warn ("Previous unbuffered result was left incomplete" )
1027
+ self ._result ._finish_unbuffered_query ()
1028
+ while self ._result .has_next :
1029
+ self .next_result ()
1030
+ self ._result = None
1028
1031
1029
1032
if isinstance (sql , text_type ):
1030
1033
sql = sql .encode (self .encoding )
@@ -1113,9 +1116,6 @@ def _request_authentication(self):
1113
1116
self .write_packet (data )
1114
1117
auth_packet = self ._read_packet ()
1115
1118
1116
- #TODO: ok packet or error packet?
1117
-
1118
-
1119
1119
def _process_auth (self , plugin_name , auth_packet ):
1120
1120
plugin_class = self ._auth_plugin_map .get (plugin_name )
1121
1121
if not plugin_class :
Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ def test_connection_gone_away(self):
418
418
with self .assertRaises (pymysql .OperationalError ) as cm :
419
419
cur .execute ("SELECT 1+1" )
420
420
# error occures while reading, not writing because of socket buffer.
421
- #self.assertEquals (cm.exception.args[0], 2006)
421
+ #self.assertEqual (cm.exception.args[0], 2006)
422
422
self .assertIn (cm .exception .args [0 ], (2006 , 2013 ))
423
423
424
424
def test_init_command (self ):
@@ -566,3 +566,11 @@ def test_previous_cursor_not_closed(self):
566
566
cur2 = con .cursor ()
567
567
with self .assertRaises (pymysql .ProgrammingError ):
568
568
cur2 .execute ("SELECT 3" )
569
+
570
+ def test_commit_during_multi_result (self ):
571
+ con = self .connections [0 ]
572
+ cur = con .cursor ()
573
+ cur .execute ("SELECT 1; SELECT 2" )
574
+ con .commit ()
575
+ cur .execute ("SELECT 3" )
576
+ self .assertEqual (cur .fetchone ()[0 ], 3 )
You can’t perform that action at this time.
0 commit comments