Method: Sequel::MySQL::Dataset#fetch_rows
- Defined in:
- lib/sequel/adapters/mysql.rb
#fetch_rows(sql) ⇒ Object
Yield all rows matching this dataset. If the dataset is set to split multiple statements, yield arrays of hashes one per statement instead of yielding results for all statements as hashes.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/sequel/adapters/mysql.rb', line 305 def fetch_rows(sql) execute(sql) do |r| i = -1 cps = db.conversion_procs cols = r.fetch_fields.map do |f| # Pretend tinyint is another integer type if its length is not 1, to # avoid casting to boolean if convert_tinyint_to_bool is set. type_proc = f.type == 1 && (f) ? cps[2] : cps[f.type] [output_identifier(f.name), type_proc, i+=1] end self.columns = cols.map(&:first) if opts[:split_multiple_result_sets] s = [] yield_rows(r, cols){|h| s << h} yield s else yield_rows(r, cols){|h| yield h} end end self end |