Namespace

Class/Module Index [+]

Quicksearch

JdbcSpec::Informix

Public Class Methods

adapter_matcher(name, *) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 43
def self.adapter_matcher(name, *)
  name =~ /informix/ ? self : false
end
column_selector() click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 47
def self.column_selector
  [ /informix/,
    lambda { |cfg, column| column.extend(::JdbcSpec::Informix::Column) } ]
end
extended(base) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 39
def self.extended(base)
  @@db_major_version = base.select_one("SELECT dbinfo('version', 'major') version FROM systables WHERE tabid = 1")['version'].to_i
end

Public Instance Methods

add_limit_offset!(sql, options) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 91
def add_limit_offset!(sql, options)
  if options[:limit]
    limit = "FIRST #{options[:limit]}"
    # SKIP available only in IDS >= 10
    offset = (@@db_major_version >= 10 && options[:offset]?
              "SKIP #{options[:offset]}" : "")
    sql.sub!(/^select /, "SELECT #{offset} #{limit} ")
  end
  sql
end
create_table(name, options = {}) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 122
def create_table(name, options = {})
  super(name, options)
  execute("CREATE SEQUENCE #{name}_seq")
end
default_sequence_name(table, column) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 87
def default_sequence_name(table, column)
  "#{table}_seq"
end
drop_table(name) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 132
def drop_table(name)
  super(name)
  execute("DROP SEQUENCE #{name}_seq")
end
modify_types(tp) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 64
def modify_types(tp)
  tp[:primary_key] = "SERIAL PRIMARY KEY"
  tp[:string]      = { :name => "VARCHAR", :limit => 255 }
  tp[:integer]     = { :name => "INTEGER" }
  tp[:float]       = { :name => "FLOAT" }
  tp[:decimal]     = { :name => "DECIMAL" }
  tp[:datetime]    = { :name => "DATETIME YEAR TO FRACTION(5)" }
  tp[:timestamp]   = { :name => "DATETIME YEAR TO FRACTION(5)" }
  tp[:time]        = { :name => "DATETIME HOUR TO FRACTION(5)" }
  tp[:date]        = { :name => "DATE" }
  tp[:binary]      = { :name => "BYTE" }
  tp[:boolean]     = { :name => "BOOLEAN" }
  tp
end
next_sequence_value(sequence_name) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 102
def next_sequence_value(sequence_name)
  select_one("SELECT #{sequence_name}.nextval id FROM systables WHERE tabid=1")['id']
end
prefetch_primary_key?(table_name = nil) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 79
def prefetch_primary_key?(table_name = nil)
  true
end
quote(value, column = nil) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 111
def quote(value, column = nil)
  if column && [:binary, :text].include?(column.type)
    # LOBs are updated separately by an after_save trigger.
    "NULL"
  elsif column && column.type == :date
    "'#{value.mon}/#{value.day}/#{value.year}'"
  else
    super
  end
end
quote_string(string) click to toggle source

TODO: Add some smart quoting for newlines in string and text fields.

# File lib/jdbc_adapter/jdbc_informix.rb, line 107
def quote_string(string)
  string.gsub(/\'/, "''")
end
remove_index(table_name, options = {}) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 137
def remove_index(table_name, options = {})
  @connection.execute_update("DROP INDEX #{index_name(table_name, options)}")
end
rename_table(name, new_name) click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 127
def rename_table(name, new_name)
  execute("RENAME TABLE #{name} TO #{new_name}")
  execute("RENAME SEQUENCE #{name}_seq TO #{new_name}_seq")
end
supports_migrations?() click to toggle source
# File lib/jdbc_adapter/jdbc_informix.rb, line 83
def supports_migrations?
  true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.