respect :symbolize_keys option for Mysql2::Result#fields if it's called before the first row is built
This commit is contained in:
parent
923393351a
commit
2bb8721e84
@ -237,9 +237,16 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID timezone, int symbolizeKey
|
||||
static VALUE rb_mysql_result_fetch_fields(VALUE self) {
|
||||
mysql2_result_wrapper * wrapper;
|
||||
unsigned int i = 0;
|
||||
short int symbolizeKeys = 0;
|
||||
VALUE defaults;
|
||||
|
||||
GetMysql2Result(self, wrapper);
|
||||
|
||||
defaults = rb_iv_get(self, "@query_options");
|
||||
if (rb_hash_aref(defaults, sym_symbolize_keys) == Qtrue) {
|
||||
symbolizeKeys = 1;
|
||||
}
|
||||
|
||||
if (wrapper->fields == Qnil) {
|
||||
wrapper->numberOfFields = mysql_num_fields(wrapper->result);
|
||||
wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
|
||||
@ -247,7 +254,7 @@ static VALUE rb_mysql_result_fetch_fields(VALUE self) {
|
||||
|
||||
if (RARRAY_LEN(wrapper->fields) != wrapper->numberOfFields) {
|
||||
for (i=0; i<wrapper->numberOfFields; i++) {
|
||||
rb_mysql_result_fetch_field(self, i, 0);
|
||||
rb_mysql_result_fetch_field(self, i, symbolizeKeys);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user