@@ -417,72 +417,76 @@ static VALUE rb_mysql_result_fetch_fields(VALUE self) {
417
417
return wrapper -> fields ;
418
418
}
419
419
420
- static VALUE rb_mysql_result_each (int argc , VALUE * argv , VALUE self ) {
421
- VALUE defaults , opts , block ;
422
- ID db_timezone , app_timezone , dbTz , appTz ;
423
- mysql2_result_wrapper * wrapper ;
424
- unsigned long i ;
425
- int symbolizeKeys = 0 , asArray = 0 , castBool = 0 , cacheRows = 1 , cast = 1 , streaming = 0 ;
426
- MYSQL_FIELD * fields = NULL ;
427
-
428
- GetMysql2Result (self , wrapper );
429
-
430
- defaults = rb_iv_get (self , "@query_options" );
431
- Check_Type (defaults , T_HASH );
432
- if (rb_scan_args (argc , argv , "01&" , & opts , & block ) == 1 ) {
433
- opts = rb_funcall (defaults , intern_merge , 1 , opts );
434
- } else {
435
- opts = defaults ;
436
- }
420
+ static void rb_mysql_row_query_options (VALUE opts , ID * db_timezone , ID * app_timezone , int * symbolizeKeys , int * asArray , int * castBool , int * cast , int * streaming , int * cacheRows ) {
421
+ ID dbTz , appTz ;
437
422
438
423
if (rb_hash_aref (opts , sym_symbolize_keys ) == Qtrue ) {
439
- symbolizeKeys = 1 ;
424
+ * symbolizeKeys = 1 ;
440
425
}
441
426
442
427
if (rb_hash_aref (opts , sym_as ) == sym_array ) {
443
- asArray = 1 ;
428
+ * asArray = 1 ;
444
429
}
445
430
446
431
if (rb_hash_aref (opts , sym_cast_booleans ) == Qtrue ) {
447
- castBool = 1 ;
432
+ * castBool = 1 ;
448
433
}
449
434
450
- if (rb_hash_aref (opts , sym_cache_rows ) == Qfalse ) {
451
- cacheRows = 0 ;
435
+ if (rb_hash_aref (opts , sym_cast ) == Qfalse ) {
436
+ * cast = 0 ;
452
437
}
453
438
454
- if (rb_hash_aref (opts , sym_cast ) == Qfalse ) {
455
- cast = 0 ;
439
+ if (rb_hash_aref (opts , sym_cache_rows ) == Qfalse ) {
440
+ * cacheRows = 0 ;
456
441
}
457
442
458
443
if (rb_hash_aref (opts , sym_stream ) == Qtrue ) {
459
- streaming = 1 ;
444
+ * streaming = 1 ;
460
445
}
461
446
462
- if (streaming && cacheRows ) {
447
+ if (* streaming && * cacheRows ) {
463
448
rb_warn ("cacheRows is ignored if streaming is true" );
464
449
}
465
450
466
451
dbTz = rb_hash_aref (opts , sym_database_timezone );
467
452
if (dbTz == sym_local ) {
468
- db_timezone = intern_local ;
453
+ * db_timezone = intern_local ;
469
454
} else if (dbTz == sym_utc ) {
470
- db_timezone = intern_utc ;
455
+ * db_timezone = intern_utc ;
471
456
} else {
472
457
if (!NIL_P (dbTz )) {
473
458
rb_warn (":database_timezone option must be :utc or :local - defaulting to :local" );
474
459
}
475
- db_timezone = intern_local ;
460
+ * db_timezone = intern_local ;
476
461
}
477
462
478
463
appTz = rb_hash_aref (opts , sym_application_timezone );
479
464
if (appTz == sym_local ) {
480
- app_timezone = intern_local ;
465
+ * app_timezone = intern_local ;
481
466
} else if (appTz == sym_utc ) {
482
- app_timezone = intern_utc ;
467
+ * app_timezone = intern_utc ;
468
+ } else {
469
+ * app_timezone = Qnil ;
470
+ }
471
+ }
472
+
473
+ static VALUE rb_mysql_result_each (int argc , VALUE * argv , VALUE self ) {
474
+ VALUE defaults , opts , block ;
475
+ ID db_timezone , app_timezone ;
476
+ mysql2_result_wrapper * wrapper ;
477
+ unsigned long i ;
478
+ int symbolizeKeys = 0 , asArray = 0 , castBool = 0 , cacheRows = 1 , cast = 1 , streaming = 0 ;
479
+
480
+ GetMysql2Result (self , wrapper );
481
+
482
+ defaults = rb_iv_get (self , "@query_options" );
483
+ Check_Type (defaults , T_HASH );
484
+ if (rb_scan_args (argc , argv , "01&" , & opts , & block ) == 1 ) {
485
+ opts = rb_funcall (defaults , intern_merge , 1 , opts );
483
486
} else {
484
- app_timezone = Qnil ;
487
+ opts = defaults ;
485
488
}
489
+ rb_mysql_row_query_options (opts , & db_timezone , & app_timezone , & symbolizeKeys , & asArray , & castBool , & cast , & streaming , & cacheRows );
486
490
487
491
if (wrapper -> lastRowProcessed == 0 ) {
488
492
if (streaming ) {
0 commit comments