# File lib/active_record/connection_adapters/firebird_adapter.rb, line 52 def primary_keys(table_name) raise ArgumentError unless table_name.present? names = query_values(<<~SQL, "SCHEMA") SELECT s.rdb$field_name FROM rdb$indices i JOIN rdb$index_segments s ON i.rdb$index_name = s.rdb$index_name LEFT JOIN rdb$relation_constraints c ON i.rdb$index_name = c.rdb$index_name WHERE i.rdb$relation_name = '#{table_name.upcase}' AND c.rdb$constraint_type = 'PRIMARY KEY'; SQL names.map(&:strip).map(&:downcase) end
class ActiveRecord::ConnectionAdapters::FirebirdAdapter
Constants
- ADAPTER_NAME
- DEFAULT_ENCODING
Public Instance Methods
active?()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 29 def active? return false unless @connection.open? @connection.query("SELECT 1 FROM RDB$DATABASE") true rescue false end
arel_visitor()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 21 def arel_visitor @arel_visitor ||= Arel::Visitors::Firebird.new(self) end
disconnect!()
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 43 def disconnect! super @connection.close rescue nil end
encoding()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 70 def encoding @connection.encoding end
log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 74 def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil) # :doc: sql = sql.encode('UTF-8', encoding) if sql.encoding.to_s == encoding super end
prefetch_primary_key?(table_name = nil)
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 25 def prefetch_primary_key?(table_name = nil) true end
primary_keys(table_name)
click to toggle source
reconnect!()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 38 def reconnect! disconnect! @connection = ::Fb::Database.connect(@config) end
reset!()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 48 def reset! reconnect! end
supports_foreign_keys?()
click to toggle source
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 79 def supports_foreign_keys? true end
Protected Instance Methods
translate_exception(e, message)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/firebird_adapter.rb, line 85 def translate_exception(e, message) case e.message when /violation of FOREIGN KEY constraint/ ActiveRecord::InvalidForeignKey.new(message) when /violation of PRIMARY or UNIQUE KEY constraint/, /attempt to store duplicate value/ ActiveRecord::RecordNotUnique.new(message) when /This operation is not defined for system tables/ ActiveRecord::ActiveRecordError.new(message) else super end end