From c21fdf31a52cbe507ff675815c29e5eef39e0bbb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 30 Oct 2005 08:10:04 +0000 Subject: Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) (closes #2644) [Dan Peterson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2825 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../abstract/connection_specification.rb | 4 ++-- .../active_record/connection_adapters/sqlite_adapter.rb | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 7858d08b66..a20304ea62 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -27,13 +27,13 @@ module ActiveRecord # # ActiveRecord::Base.establish_connection( # :adapter => "sqlite", - # :dbfile => "path/to/dbfile" + # :database => "path/to/dbfile" # ) # # Also accepts keys as strings (for parsing from yaml for example): # ActiveRecord::Base.establish_connection( # "adapter" => "sqlite", - # "dbfile" => "path/to/dbfile" + # "database" => "path/to/dbfile" # ) # # The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index f0c2cc06d4..3a53b59d1a 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -15,7 +15,7 @@ module ActiveRecord end db = SQLite3::Database.new( - config[:dbfile], + config[:database], :results_as_hash => true, :type_translation => false ) @@ -29,7 +29,7 @@ module ActiveRecord unless self.class.const_defined?(:SQLite) require_library_or_gem(config[:adapter]) - db = SQLite::Database.new(config[:dbfile], 0) + db = SQLite::Database.new(config[:database], 0) db.show_datatypes = "ON" if !defined? SQLite::Version db.results_as_hash = true if defined? SQLite::Version db.type_translation = false @@ -45,16 +45,17 @@ module ActiveRecord private def parse_config!(config) - # Require dbfile. - unless config.has_key?(:dbfile) - raise ArgumentError, "No database file specified. Missing argument: dbfile" + config[:database] ||= config[:dbfile] + # Require database. + unless config.has_key?(:database) + raise ArgumentError, "No database file specified. Missing argument: database" end # Allow database path relative to RAILS_ROOT, but only if # the database path is not the special path that tells # Sqlite build a database only in memory. - if Object.const_defined?(:RAILS_ROOT) && ':memory:' != config[:dbfile] - config[:dbfile] = File.expand_path(config[:dbfile], RAILS_ROOT) + if Object.const_defined?(:RAILS_ROOT) && ':memory:' != config[:database] + config[:database] = File.expand_path(config[:database], RAILS_ROOT) end end end @@ -88,7 +89,7 @@ module ActiveRecord # # Options: # - # * :dbfile -- Path to the database file. + # * :database -- Path to the database file. class SQLiteAdapter < AbstractAdapter def adapter_name #:nodoc: 'SQLite' -- cgit v1.2.3