Class | Sequel::IBMDB::Dataset |
In: |
lib/sequel/adapters/ibmdb.rb
|
Parent: | Sequel::Dataset |
DatasetClass | = | self |
convert_smallint_to_bool | [W] | Override the default IBMDB.convert_smallint_to_bool setting for this dataset. |
Emulate support of bind arguments in called statements.
# File lib/sequel/adapters/ibmdb.rb, line 394 394: def call(type, bind_arguments={}, *values, &block) 395: ps = to_prepared_statement(type, values) 396: ps.extend(CallableStatementMethods) 397: ps.call(bind_arguments, &block) 398: end
Whether to convert smallint to boolean arguments for this dataset. Defaults to the IBMDB module setting.
# File lib/sequel/adapters/ibmdb.rb, line 402 402: def convert_smallint_to_bool 403: defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = IBMDB.convert_smallint_to_bool) 404: end
Fetch the rows from the database and yield plain hashes.
# File lib/sequel/adapters/ibmdb.rb, line 410 410: def fetch_rows(sql) 411: execute(sql) do |stmt| 412: offset = @opts[:offset] 413: columns = [] 414: convert = convert_smallint_to_bool 415: cps = db.conversion_procs 416: stmt.num_fields.times do |i| 417: k = stmt.field_name i 418: key = output_identifier(k) 419: type = stmt.field_type(k).downcase.to_sym 420: # decide if it is a smallint from precision 421: type = :boolean if type ==:int && convert && stmt.field_precision(k) < 8 422: columns << [key, cps[type]] 423: end 424: cols = columns.map{|c| c.at(0)} 425: cols.delete(row_number_column) if offset 426: @columns = cols 427: 428: while res = stmt.fetch_array 429: row = {} 430: res.zip(columns).each do |v, (k, pr)| 431: row[k] = ((pr ? pr.call(v) : v) if v) 432: end 433: row.delete(row_number_column) if offset 434: yield row 435: end 436: end 437: self 438: end
Store the given type of prepared statement in the associated database with the given name.
# File lib/sequel/adapters/ibmdb.rb, line 442 442: def prepare(type, name=nil, *values) 443: ps = to_prepared_statement(type, values) 444: ps.extend(PreparedStatementMethods) 445: if name 446: ps.prepared_statement_name = name 447: db.set_prepared_statement(name, ps) 448: end 449: ps 450: end