Namespace

Class/Module Index [+]

Quicksearch

JdbcSpec::HSQLDB

Public Class Methods

adapter_matcher(name, *) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 19
def self.adapter_matcher(name, *)
  name =~ /hsqldb/ ? self : false
end
column_selector() click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 23
def self.column_selector
  [/hsqldb|\.h2\./, lambda {|cfg,col| col.extend(::JdbcSpec::HSQLDB::Column)}]
end

Public Instance Methods

_execute(sql, name = nil) click to toggle source

Override normal #_execute: See Rubyforge #11567

# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 166
def _execute(sql, name = nil)
  if ::ActiveRecord::ConnectionAdapters::JdbcConnection::select?(sql)
    @connection.execute_query(sql)
  elsif ::ActiveRecord::ConnectionAdapters::JdbcConnection::insert?(sql)
    insert(sql, name)
  else
    @connection.execute_update(sql)
  end
end
add_column(table_name, column_name, type, options = {}) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 118
def add_column(table_name, column_name, type, options = {})
  if option_not_null = options[:null] == false
    option_not_null = options.delete(:null)
  end
  add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
  add_column_options!(add_column_sql, options)
  execute(add_column_sql)
  if option_not_null
    alter_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ALTER #{quote_column_name(column_name)} NOT NULL"
  end
end
last_insert_id(table, sequence_name) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 161
def last_insert_id(table, sequence_name)
  Integer(select_value("CALL IDENTITY()"))
end
modify_types(tp) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 61
def modify_types(tp)
  tp[:primary_key] = "INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) PRIMARY KEY"
  tp[:integer][:limit] = nil
  tp[:boolean][:limit] = nil
  # set text and float limits so we don't see odd scales tacked on
  # in migrations
  tp[:boolean] = { :name => "tinyint" }
  tp[:text][:limit] = nil
  tp[:float][:limit] = 17 if defined?(::Jdbc::H2)
  tp[:string][:limit] = 255
  tp[:datetime] = { :name => "DATETIME" }
  tp[:timestamp] = { :name => "DATETIME" }
  tp[:time] = { :name => "TIME" }
  tp[:date] = { :name => "DATE" }
  tp
end
quote_string(str) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 106
def quote_string(str)
  str.gsub(/'/, "''")
end
quoted_false() click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 114
def quoted_false
  '0'
end
quoted_true() click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 110
def quoted_true
  '1'
end
remove_index(table_name, options = {}) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 196
def remove_index(table_name, options = {})
  execute "DROP INDEX #{quote_column_name(index_name(table_name, options))}"
end
rename_table(name, new_name) click to toggle source
# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 149
def rename_table(name, new_name)
  execute "ALTER TABLE #{name} RENAME TO #{new_name}"
end
tables() click to toggle source

override to filter out system tables that otherwise end up in db/schema.rb during migrations. JdbcConnection#tables now takes an optional block filter so we can screen out rows corresponding to system tables. HSQLDB names its system tables SYSTEM.*, but H2 seems to name them without any kind of convention

# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 192
def tables
  @connection.tables.select {|row| row.to_s !~ /^system_/ }
end
type_to_sql(type, limit = nil, precision = nil, scale = nil) click to toggle source

Maps logical Rails types to MySQL-specific data types.

# File lib/jdbc_adapter/jdbc_hsqldb.rb, line 143
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
  return super if defined?(::Jdbc::H2) || type.to_s != 'integer' || limit == nil

  type
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.