diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-30 08:10:04 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-30 08:10:04 +0000 |
commit | c21fdf31a52cbe507ff675815c29e5eef39e0bbb (patch) | |
tree | e782c60828c1632273e04aacfb197805c74b4b44 /activerecord | |
parent | ea44527afd55b568be3a07cb0d4991242474db03 (diff) | |
download | rails-c21fdf31a52cbe507ff675815c29e5eef39e0bbb.tar.gz rails-c21fdf31a52cbe507ff675815c29e5eef39e0bbb.tar.bz2 rails-c21fdf31a52cbe507ff675815c29e5eef39e0bbb.zip |
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
Diffstat (limited to 'activerecord')
7 files changed, 19 insertions, 16 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 8dca6b1535..c7f4a0ff91 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Changed :dbfile to :database for SQLite adapter for consistency (old key still works as an alias) #2644 [Dan Peterson] + * Added migration support for Oracle #2647 [Michael Schoen] * Worked around that connection can't be reset if allow_concurrency is off. #2648 [Michael Schoen <schoenm@earthlink.net>] diff --git a/activerecord/README b/activerecord/README index 300ce8a495..bffa2ab65d 100755 --- a/activerecord/README +++ b/activerecord/README @@ -165,7 +165,7 @@ A short rundown of the major features: * Database abstraction through simple adapters (~100 lines) with a shared connector - ActiveRecord::Base.establish_connection(:adapter => "sqlite", :dbfile => "dbfile") + ActiveRecord::Base.establish_connection(:adapter => "sqlite", :database => "dbfile") ActiveRecord::Base.establish_connection( :adapter => "mysql", 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: # - # * <tt>:dbfile</tt> -- Path to the database file. + # * <tt>:database</tt> -- Path to the database file. class SQLiteAdapter < AbstractAdapter def adapter_name #:nodoc: 'SQLite' diff --git a/activerecord/test/connections/native_sqlite/connection.rb b/activerecord/test/connections/native_sqlite/connection.rb index b686c7705b..6a08fc1f8e 100644 --- a/activerecord/test/connections/native_sqlite/connection.rb +++ b/activerecord/test/connections/native_sqlite/connection.rb @@ -18,7 +18,7 @@ def make_connection(clazz, db_file, db_definitions_file) raise SqliteError.new("Seems that there is no sqlite executable available") unless system(sqlite_command) clazz.establish_connection( :adapter => "sqlite", - :dbfile => db_file) + :database => db_file) script = File.read("#{BASE_DIR}/db_definitions/#{db_definitions_file}") # SQLite-Ruby has problems with semi-colon separated commands, so split and execute one at a time script.split(';').each do @@ -28,7 +28,7 @@ def make_connection(clazz, db_file, db_definitions_file) else clazz.establish_connection( :adapter => "sqlite", - :dbfile => db_file) + :database => db_file) end end diff --git a/activerecord/test/connections/native_sqlite3/connection.rb b/activerecord/test/connections/native_sqlite3/connection.rb index 07856cc677..917f7129da 100644 --- a/activerecord/test/connections/native_sqlite3/connection.rb +++ b/activerecord/test/connections/native_sqlite3/connection.rb @@ -18,7 +18,7 @@ def make_connection(clazz, db_file, db_definitions_file) raise SqliteError.new("Seems that there is no sqlite3 executable available") unless system(sqlite_command) clazz.establish_connection( :adapter => "sqlite3", - :dbfile => db_file) + :database => db_file) script = File.read("#{BASE_DIR}/db_definitions/#{db_definitions_file}") # SQLite-Ruby has problems with semi-colon separated commands, so split and execute one at a time script.split(';').each do @@ -28,7 +28,7 @@ def make_connection(clazz, db_file, db_definitions_file) else clazz.establish_connection( :adapter => "sqlite3", - :dbfile => db_file) + :database => db_file) end end diff --git a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb index d11a5fe8c8..9e0414ba88 100644 --- a/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +++ b/activerecord/test/connections/native_sqlite3/in_memory_connection.rb @@ -7,7 +7,7 @@ class SqliteError < StandardError end def make_connection(clazz, db_definitions_file) - clazz.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:') + clazz.establish_connection(:adapter => 'sqlite3', :database => ':memory:') File.read("#{File.dirname(__FILE__)}/../../fixtures/db_definitions/#{db_definitions_file}").split(';').each do |command| clazz.connection.execute(command) unless command.strip.empty? end |