adamlofts / mysql1_dart

MySQL driver for Dart
Other
134 stars 46 forks source link

LateInitializationError throwed from conn.query() #96

Closed wahtherewahhere closed 2 years ago

wahtherewahhere commented 3 years ago

Hi,

I try to use this package to connect to mysql. My version of mysql1 is 0.19.2. The following code throws exception LateInitializationError: Field '_parametersToRead@51458213' has not been initialized.

results = await conn.query("INSERT INTO atable (acolume) VALUES ( ? )", ['testdata']);

The error stack is following:

LateInitializationError: Field '_parametersToRead@51458213' has not been initialized.                  
package:mysql1/src/prepared_statements/prepare_handler.dart        PrepareHandler._parametersToRead    
package:mysql1/src/prepared_statements/prepare_handler.dart 47:52  PrepareHandler.processResponse      
package:mysql1/src/single_connection.dart 349:32                   ReqRespConnection._handleData       
package:mysql1/src/single_connection.dart 318:13                   ReqRespConnection._handleHeader     
===== asynchronous gap ===========================                                                     
dart:async                                                         _Completer.completeError            
package:mysql1/src/single_connection.dart 291:19                   ReqRespConnection.handleError       
package:mysql1/src/single_connection.dart 387:7                    ReqRespConnection._handleData       
package:mysql1/src/single_connection.dart 318:13                   ReqRespConnection._handleHeader     
===== asynchronous gap ===========================                                                     
dart:async                                                         _asyncThenWrapperHelper             
package:mysql1/src/single_connection.dart 303:13                   ReqRespConnection._readPacket       
===== asynchronous gap ===========================                                                     
dart:async                                                         _asyncThenWrapperHelper             
package:mysql1/src/single_connection.dart 141:13                   MySqlConnection.connect.<fn>        
package:mysql1/src/buffered_socket.dart 105:22                     BufferedSocket._onData              
===== asynchronous gap ===========================                                                     
dart:io                                                            _RawSocket.listen                   
package:mysql1/src/buffered_socket.dart 47:29                      new BufferedSocket._                
package:mysql1/src/buffered_socket.dart 93:27                      BufferedSocket.connect              
===== asynchronous gap ===========================                                                     
dart:async                                                         _asyncThenWrapperHelper             
package:mysql1/src/single_connection.dart 139:39                   MySqlConnection.connect             

if I rewrite the query into this then everything fine.

results = await conn.query("INSERT INTO atable (acolume) VALUES ('testdata')");

Look like that the placeholder doesn't work properly. I found that the property _parametersToRead is not initialize by anyone. How do I fix this problem?

Thanks.

giann commented 2 years ago

Same issue for me