Class: ActiveRecord::ConnectionAdapters::FirebirdAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::FirebirdAdapter
- Includes:
- ActiveRecord::ConnectionAdapters::Firebird::DatabaseLimits, ActiveRecord::ConnectionAdapters::Firebird::DatabaseStatements, ActiveRecord::ConnectionAdapters::Firebird::Quoting, ActiveRecord::ConnectionAdapters::Firebird::SchemaStatements
- Defined in:
- lib/active_record/connection_adapters/firebird_adapter.rb
Constant Summary collapse
- ADAPTER_NAME =
"Firebird".freeze
- DEFAULT_ENCODING =
"Windows-1252".freeze
Instance Method Summary collapse
- #active? ⇒ Boolean
- #arel_visitor ⇒ Object
- #disconnect! ⇒ Object
- #encoding ⇒ Object
-
#log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil) ⇒ Object
:doc:.
- #prefetch_primary_key?(table_name = nil) ⇒ Boolean
- #primary_keys(table_name) ⇒ Object
- #reconnect! ⇒ Object
- #reset! ⇒ Object
- #supports_foreign_keys? ⇒ Boolean
Instance Method Details
#active? ⇒ Boolean
29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
21 22 23 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 21 def arel_visitor @arel_visitor ||= Arel::Visitors::Firebird.new(self) end |
#disconnect! ⇒ Object
43 44 45 46 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 43 def disconnect! super @connection.close rescue nil end |
#encoding ⇒ Object
70 71 72 |
# 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) ⇒ Object
:doc:
74 75 76 77 |
# 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) ⇒ Boolean
25 26 27 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 25 def prefetch_primary_key?(table_name = nil) true end |
#primary_keys(table_name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 |
#reconnect! ⇒ Object
38 39 40 41 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 38 def reconnect! disconnect! @connection = ::Fb::Database.connect(@config) end |
#reset! ⇒ Object
48 49 50 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 48 def reset! reconnect! end |
#supports_foreign_keys? ⇒ Boolean
79 80 81 |
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 79 def supports_foreign_keys? true end |