@@ -647,7 +647,6 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
647647 struct async_query_args async_args ;
648648#endif
649649 struct nogvl_send_query_args args ;
650- int async = 0 ;
651650 VALUE thread_current = rb_thread_current ();
652651 GET_CLIENT (self );
653652
@@ -658,8 +657,6 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
658657 Check_Type (current , T_HASH );
659658 rb_iv_set (self , "@current_query_options" , current );
660659
661- async = rb_hash_aref (current , sym_async ) == Qtrue ;
662-
663660 Check_Type (sql , T_STRING );
664661#ifdef HAVE_RUBY_ENCODING_H
665662 /* ensure the string is in the encoding the connection is expecting */
@@ -689,15 +686,15 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
689686#ifndef _WIN32
690687 rb_rescue2 (do_send_query , (VALUE )& args , disconnect_and_raise , self , rb_eException , (VALUE )0 );
691688
692- if (!async ) {
689+ if (rb_hash_aref (current , sym_async ) == Qtrue ) {
690+ return Qnil ;
691+ } else {
693692 async_args .fd = wrapper -> client -> net .fd ;
694693 async_args .self = self ;
695694
696695 rb_rescue2 (do_query , (VALUE )& async_args , disconnect_and_raise , self , rb_eException , (VALUE )0 );
697696
698697 return rb_mysql_client_async_result (self );
699- } else {
700- return Qnil ;
701698 }
702699#else
703700 do_send_query (& args );
0 commit comments