@see ActiveRecord::ConnectionAdapters::Jdbc::ArelSupport
# File lib/arjdbc/hsqldb/adapter.rb, line 68 def self.arel_visitor_type(config = nil) require 'arel/visitors/hsqldb'; ::Arel::Visitors::HSQLDB end
# File lib/arjdbc/hsqldb/adapter.rb, line 74 def adapter_name ADAPTER_NAME end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 166 def add_column(table_name, column_name, type, options = {}) 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) end
@note Only used with (non-AREL) ActiveRecord *2.3*. @see Arel::Visitors::HSQLDB#limit_offset
# File lib/arjdbc/hsqldb/adapter.rb, line 211 def add_limit_offset!(sql, options) if sql =~ /^select/ offset = options[:offset] || 0 if limit = options[:limit] sql.replace "SELECT LIMIT #{offset} #{limit} #{sql[7..-1]}" elsif offset > 0 sql.replace "SELECT LIMIT #{offset} 0 #{sql[7..-1]}" end end end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 173 def change_column(table_name, column_name, type, options = {}) execute "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} #{type_to_sql(type, options[:limit])}" end
@private
# File lib/arjdbc/hsqldb/adapter.rb, line 269 def create_database(name = nil, options = {}); end
@private
# File lib/arjdbc/hsqldb/adapter.rb, line 272 def drop_database(name = nil) execute('DROP SCHEMA PUBLIC CASCADE') end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 223 def empty_insert_statement_value # on HSQLDB only work with tables that have a default value for each # and every column ... you'll need to avoid `Model.create!` on 4.0 'DEFAULT VALUES' end
# File lib/arjdbc/hsqldb/adapter.rb, line 197 def last_insert_id identity = select_value("CALL IDENTITY()") Integer(identity.nil? ? 0 : identity) end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 107 def native_database_types NATIVE_DATABASE_TYPES end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 112 def quote(value, column = nil) return value.quoted_id if value.respond_to?(:quoted_id) return value if sql_literal?(value) case value when String column_type = column && column.type if column_type == :binary "X'#{value.unpack("H*")[0]}'" elsif column_type == :integer || column.respond_to?(:primary) && column.primary && column.klass != String value.to_i.to_s else "'#{quote_string(value)}'" end when Time column_type = column && column.type if column_type == :time "'#{value.strftime("%H:%M:%S")}'" #elsif column_type == :timestamp # || column_type == :datetime #value = ::ActiveRecord::Base.default_timezone == :utc ? value.getutc : value.getlocal #"'#{value.strftime("%Y-%m-%d %H:%M:%S")}.#{sprintf("%06d", value.usec)}'" else super end else super end end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 156 def quote_column_name(name) name = name.to_s if name =~ /[-]/ %{"#{name.upcase}"} else name end end
Quote date/time values for use in SQL input. Includes microseconds if the value is a Time responding to usec. @override
# File lib/arjdbc/hsqldb/adapter.rb, line 145 def quoted_date(value) if value.acts_like?(:time) && value.respond_to?(:usec) usec = sprintf("%06d", value.usec) value = ::ActiveRecord::Base.default_timezone == :utc ? value.getutc : value.getlocal "#{value.strftime("%Y-%m-%d %H:%M:%S")}.#{usec}" else super end end
@private
# File lib/arjdbc/hsqldb/adapter.rb, line 263 def recreate_database(name = nil, options = {}) drop_database(name) create_database(name, options) end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 236 def remove_index(table_name, options = {}) execute "DROP INDEX #{quote_column_name(index_name(table_name, options))}" end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 193 def rename_table(name, new_name) execute "ALTER TABLE #{name} RENAME TO #{new_name}" end
# File lib/arjdbc/hsqldb/schema_creation.rb, line 6 def schema_creation SchemaCreation.new self end
# File lib/arjdbc/hsqldb/adapter.rb, line 258 def shutdown execute 'SHUTDOWN' end
@override
# File lib/arjdbc/hsqldb/adapter.rb, line 241 def structure_dump execute('SCRIPT').map do |result| # [ { 'command' => SQL }, { 'command' ... }, ... ] case sql = result.first[1] # ['command'] when /CREATE USER SA PASSWORD DIGEST .*?/ then nil when /CREATE SCHEMA PUBLIC AUTHORIZATION DBA/ then nil when /GRANT DBA TO SA/ then nil else sql end end.compact.join("\n\n") end
@see structure_dump
# File lib/arjdbc/hsqldb/adapter.rb, line 254 def structure_load(dump) dump.each_line("\n\n") { |ddl| execute(ddl) } end
Generated with the Darkfish Rdoc Generator 2.