@@ -648,7 +648,6 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
648648 struct async_query_args async_args ;
649649#endif
650650 struct nogvl_send_query_args args ;
651- int async = 0 ;
652651 GET_CLIENT (self );
653652
654653 REQUIRE_CONNECTED (wrapper );
@@ -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 */
@@ -676,15 +673,15 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
676673#ifndef _WIN32
677674 rb_rescue2 (do_send_query , (VALUE )& args , disconnect_and_raise , self , rb_eException , (VALUE )0 );
678675
679- if (!async ) {
676+ if (rb_hash_aref (current , sym_async ) == Qtrue ) {
677+ return Qnil ;
678+ } else {
680679 async_args .fd = wrapper -> client -> net .fd ;
681680 async_args .self = self ;
682681
683682 rb_rescue2 (do_query , (VALUE )& async_args , disconnect_and_raise , self , rb_eException , (VALUE )0 );
684683
685684 return rb_mysql_client_async_result (self );
686- } else {
687- return Qnil ;
688685 }
689686#else
690687 do_send_query (& args );
0 commit comments