diff options
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb | 30 |
2 files changed, 18 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 5c9912b366..844af952c1 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -15,6 +15,8 @@ require "sqlite3" module ActiveRecord module ConnectionHandling # :nodoc: def sqlite3_connection(config) + config = config.symbolize_keys + # Require database. unless config[:database] raise ArgumentError, "No database file specified. Missing argument: database" @@ -29,11 +31,9 @@ module ActiveRecord Dir.mkdir(dirname) unless File.directory?(dirname) end - db_opts = config.symbolize_keys.merge(results_as_hash: true) - db = SQLite3::Database.new( config[:database].to_s, - db_opts + config.merge(results_as_hash: true) ) db.busy_timeout(ConnectionAdapters::SQLite3Adapter.type_cast_config_to_integer(config[:timeout])) if config[:timeout] diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index 86cbe530a0..d1d4d545a3 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -505,35 +505,35 @@ module ActiveRecord end def test_db_is_not_readonly_when_readonly_option_is_false - @conn = Base.sqlite3_connection database: ":memory:", - adapter: "sqlite3", - readonly: false + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: false - assert_not_predicate(@conn.raw_connection, :readonly?) + assert_not_predicate conn.raw_connection, :readonly? end def test_db_is_not_readonly_when_readonly_option_is_unspecified - @conn = Base.sqlite3_connection database: ":memory:", - adapter: "sqlite3" + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3" - assert_not_predicate(@conn.raw_connection, :readonly?) + assert_not_predicate conn.raw_connection, :readonly? end def test_db_is_readonly_when_readonly_option_is_true - @conn = Base.sqlite3_connection database: ":memory:", - adapter: "sqlite3", - readonly: true + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: true - assert_predicate(@conn.raw_connection, :readonly?) + assert_predicate conn.raw_connection, :readonly? end def test_writes_are_not_permitted_to_readonly_databases - @conn = Base.sqlite3_connection database: ":memory:", - adapter: "sqlite3", - readonly: true + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: true assert_raises(ActiveRecord::StatementInvalid, /SQLite3::ReadOnlyException/) do - @conn.execute("CREATE TABLE test(id integer)") + conn.execute("CREATE TABLE test(id integer)") end end |