Module: ActiveRecord::ConnectionHandling
- Defined in:
- lib/active_record/connection_adapters/singlestore_adapter.rb
Overview
:nodoc:
Constant Summary collapse
- ER_BAD_DB_ERROR =
1049
Instance Method Summary collapse
-
#singlestore_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
Instance Method Details
#singlestore_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_record/connection_adapters/singlestore_adapter.rb', line 16 def singlestore_connection(config) config = config.symbolize_keys config[:username] = "root" if config[:username].nil? config[:flags] ||= 0 config[:variables] = {sql_mode: ''} if config[:variables].nil? if config[:flags].kind_of? Array config[:flags].push "FOUND_ROWS" else config[:flags] |= Mysql2::Client::FOUND_ROWS end client = Mysql2::Client.new(config) ConnectionAdapters::SinglestoreAdapter.new(client, logger, nil, config) rescue Mysql2::Error => error if error.error_number == ER_BAD_DB_ERROR raise ActiveRecord::NoDatabaseError else raise end end |