class Sequel::IBMDB::Dataset

Constants

PreparedStatementMethods

Public Instance Methods

convert_smallint_to_bool() click to toggle source

Whether to convert smallint to boolean arguments for this dataset. Defaults to the IBMDB module setting.

# File lib/sequel/adapters/ibmdb.rb, line 382
def convert_smallint_to_bool
  opts.has_key?(:convert_smallint_to_bool) ? opts[:convert_smallint_to_bool] : IBMDB.convert_smallint_to_bool
end
convert_smallint_to_bool=(v) click to toggle source

Override the default Sequel::IBMDB.convert_smallint_to_bool setting for this dataset.

# File lib/sequel/adapters/ibmdb.rb, line 376
def convert_smallint_to_bool=(v)
  @opts[:convert_smallint_to_bool] = v
end
fetch_rows(sql) { |row| ... } click to toggle source

Fetch the rows from the database and yield plain hashes.

# File lib/sequel/adapters/ibmdb.rb, line 392
def fetch_rows(sql)
  execute(sql) do |stmt|
    columns = []
    convert = convert_smallint_to_bool
    cps = db.conversion_procs
    stmt.num_fields.times do |i|
      k = stmt.field_name i
      key = output_identifier(k)
      type = stmt.field_type(i).downcase.to_sym
      # decide if it is a smallint from precision
      type = :boolean  if type == :int && convert && stmt.field_precision(i) < 8
      type = :blob if type == :clob && Sequel::DB2.use_clob_as_blob
      columns << [key, cps[type]]
    end
    cols = columns.map{|c| c.at(0)}
    self.columns = cols

    while res = stmt.fetch_array
      row = {}
      res.zip(columns).each do |v, (k, pr)|
        row[k] = ((pr ? pr.call(v) : v) if v)
      end
      yield row
    end
  end
  self
end
with_convert_smallint_to_bool(v) click to toggle source

Return a cloned dataset with the #convert_smallint_to_bool option set.

# File lib/sequel/adapters/ibmdb.rb, line 387
def with_convert_smallint_to_bool(v)
  clone(:convert_smallint_to_bool=>v)
end

Private Instance Methods

bound_variable_modules() click to toggle source
# File lib/sequel/adapters/ibmdb.rb, line 422
def bound_variable_modules
  [CallableStatementMethods]
end
prepared_statement_modules() click to toggle source
# File lib/sequel/adapters/ibmdb.rb, line 426
def prepared_statement_modules
  [PreparedStatementMethods]
end