# File lib/arjdbc/nuodb/adapter.rb, line 311 def primary_keys(table) @connection.primary_keys(qualify_table(table)) end
module ArJdbc::NuoDB
Constants
- ADAPTER_NAME
ADAPTER SUPPORT ========================================================
- LOST_CONNECTION_ERROR_MESSAGES
DATABASE STATEMENTS ====================================================
- NATIVE_DATABASE_TYPES
- VERSION
Public Class Methods
arel2_visitors(config)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 11 def self.arel2_visitors(config) {}.tap { |v| %w(nuodb).each { |a| v[a] = ::Arel::Visitors::NuoDB } } end
column_selector()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 7 def self.column_selector [/nuodb/i, lambda { |cfg, col| col.extend(::ArJdbc::NuoDB::ColumnExtensions) }] end
Public Instance Methods
adapter_name()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 78 def adapter_name ADAPTER_NAME end
begin_db_transaction()
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 279 def begin_db_transaction tries ||= 2 super rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError => exception if LOST_CONNECTION_ERROR_MESSAGES.any? { |msg| exception.message =~ /#{msg}/ } reconnect! retry unless (tries -= 1).zero? end raise end
columns(table_name, name=nil)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 184 def columns(table_name, name=nil) #puts "called columns" @connection.columns_internal(table_name.to_s, name, nuodb_schema) end
commit_db_transaction()
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 290 def commit_db_transaction super rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError => exception if LOST_CONNECTION_ERROR_MESSAGES.any? { |msg| exception.message =~ /#{msg}/ } reconnect! end raise end
create_savepoint()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 94 def create_savepoint execute("SAVEPOINT #{current_savepoint_name}") end
execute(sql, name = nil, binds = [])
click to toggle source
Monkey patch the execute method as reconnect is broken in the underlying Rails infrastructure; see these bug numbers and references:
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 266 def execute(sql, name = nil, binds = []) tries ||= 2 super(sql, name, binds) rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError => exception if LOST_CONNECTION_ERROR_MESSAGES.any? { |msg| exception.message =~ /#{msg}/ } if open_transactions == 0 reconnect! retry unless (tries -= 1).zero? end end raise end
indexes(table_name, name = nil, schema_name = nil)
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 179 def indexes(table_name, name = nil, schema_name = nil) #puts "called columns" super end
modify_types(tp)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 106 def modify_types(tp) tp[:primary_key] = 'int not null generated always primary key' tp[:boolean] = {:name => 'boolean'} tp[:date] = {:name => 'date', :limit => nil} tp[:datetime] = {:name => 'timestamp', :limit => nil} tp[:decimal] = {:name => 'decimal'} tp[:integer] = {:name => 'int', :limit => 4} tp[:string] = {:name => 'string'} tp[:time] = {:name => 'time', :limit => nil} tp[:timestamp] = {:name => 'timestamp', :limit => nil} tp end
native_database_types()
click to toggle source
Maps logical rails types to NuoDB
types.
# File lib/arjdbc/nuodb/adapter.rb, line 74 def native_database_types NATIVE_DATABASE_TYPES end
primary_keys(table)
click to toggle source
CONNECTION POOL ========================================================
quote(value, column = nil)
click to toggle source
QUOTING ================================================================
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 130 def quote(value, column = nil) case value when TrueClass, FalseClass value.to_s else super end end
quote_column_name(name)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 139 def quote_column_name(name) "`#{name.to_s.gsub('`', '``')}`" end
quote_table_name(name)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 143 def quote_table_name(name) quote_column_name(name).gsub('.', '`.`') end
quoted_date(value)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 160 def quoted_date(value) if value.acts_like?(:time) zone_conversion_method = :getutc if value.respond_to?(zone_conversion_method) value = value.send(zone_conversion_method) end end value.to_s(:db) end
quoted_false()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 156 def quoted_false "'false'" end
quoted_true()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 152 def quoted_true "'true'" end
release_savepoint()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 102 def release_savepoint execute("RELEASE SAVEPOINT #{current_savepoint_name}") end
rename_column(table_name, column_name, new_column_name)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 231 def rename_column(table_name, column_name, new_column_name) raise NotImplementedError, 'rename_column is not implemented' end
rename_table(table_name, new_name)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 235 def rename_table(table_name, new_name) raise NotImplementedError, 'rename_table is not implemented' end
rollback_db_transaction()
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 299 def rollback_db_transaction super rescue ActiveRecord::StatementInvalid, ActiveRecord::JDBCError => exception if LOST_CONNECTION_ERROR_MESSAGES.any? { |msg| exception.message =~ /#{msg}/ } reconnect! else raise end end
rollback_to_savepoint()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 98 def rollback_to_savepoint execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}") end
supports_ddl_transactions?()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 86 def supports_ddl_transactions? true end
supports_index_sort_order?()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 90 def supports_index_sort_order? true end
supports_savepoints?()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 82 def supports_savepoints? true end
tables(name = nil)
click to toggle source
SCHEMA STATEMENTS ======================================================
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 174 def tables(name = nil) #puts "called columns" super end
type_cast(value)
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 147 def type_cast(value) return super unless value == true || value == false value ? true : false end
type_to_sql(type, limit = nil, precision = nil, scale = nil)
click to toggle source
maps logical rails types to nuodb-specific data types.
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 190 def type_to_sql(type, limit = nil, precision = nil, scale = nil) case type.to_s when 'integer' return 'integer' unless limit case limit when 1..2 'smallint' when 3..4 'integer' when 5..8 'bigint' else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.") end when 'timestamp' column_type_sql = 'timestamp' unless precision.nil? case precision when 0..9 column_type_sql << "(#{precision})" else nil end end column_type_sql when 'time' column_type_sql = 'time' unless precision.nil? case precision when 0..9 column_type_sql << "(#{precision})" else nil end end column_type_sql else super end end
Protected Instance Methods
translate_exception(exception, message)
click to toggle source
Calls superclass method
# File lib/arjdbc/nuodb/adapter.rb, line 121 def translate_exception(exception, message) # future translations here... super end
Private Instance Methods
nuodb_schema()
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 325 def nuodb_schema config[:schema] || '' end
qualify_table(table)
click to toggle source
# File lib/arjdbc/nuodb/adapter.rb, line 317 def qualify_table(table) if (table.include? '.') || @config[:schema].blank? table else nuodb_schema + '.' + table end end