diff --git a/ext/mysql2/result.c b/ext/mysql2/result.c index 02f70f0..0801030 100644 --- a/ext/mysql2/result.c +++ b/ext/mysql2/result.c @@ -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; inumberOfFields; i++) { - rb_mysql_result_fetch_field(self, i, 0); + rb_mysql_result_fetch_field(self, i, symbolizeKeys); } }