diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 31 | ||||
-rw-r--r-- | activerecord/lib/active_record/scoping/default.rb | 14 | ||||
-rw-r--r-- | activerecord/lib/active_record/version.rb | 4 |
4 files changed, 32 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index d8340bf1c9..da72d1718e 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -10,7 +10,6 @@ require 'zlib' require 'active_support/dependencies' require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/object/blank' -require 'active_support/core_ext/logger' require 'active_support/ordered_hash' require 'active_record/fixtures/file' diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 0d1d9845ae..199eee4359 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -446,26 +446,39 @@ db_namespace = namespace :db do end namespace :test do - # desc "Recreate the test database from the current schema.rb" + + # desc "Recreate the test database from the current schema" task :load => 'db:test:purge' do - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) - ActiveRecord::Schema.verbose = false - db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby + case ActiveRecord::Base.schema_format + when :ruby + db_namespace["test:load_schema"].invoke + when :sql + db_namespace["test:load_structure"].invoke + end + end + # desc "Recreate the test database from an existent structure.sql file" + task :load_structure => 'db:test:purge' do begin old_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], 'test' - db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace["structure:load"].invoke ensure ENV['RAILS_ENV'] = old_env end + end + # desc "Recreate the test database from an existent schema.rb file" + task :load_schema => 'db:test:purge' do + ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) + ActiveRecord::Schema.verbose = false + db_namespace["schema:load"].invoke end - # desc "Recreate the test database from the current environment's database schema" - task :clone => %w(db:schema:dump db:test:load) + # desc "Recreate the test database from a fresh schema.rb file" + task :clone => %w(db:schema:dump db:test:load_schema) - # desc "Recreate the test databases from the structure.sql file" - task :clone_structure => [ "db:structure:dump", "db:test:load" ] + # desc "Recreate the test database from a fresh structure.sql file" + task :clone_structure => [ "db:structure:dump", "db:test:load_structure" ] # desc "Empty the test database" task :purge => :environment do diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index 9840cbccae..6b5070808a 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -12,7 +12,7 @@ module ActiveRecord end module ClassMethods - # Returns a scope for this class without taking into account the default_scope. + # Returns a scope for the model without the default_scope. # # class Post < ActiveRecord::Base # def self.default_scope @@ -23,18 +23,20 @@ module ActiveRecord # Post.all # Fires "SELECT * FROM posts WHERE published = true" # Post.unscoped.all # Fires "SELECT * FROM posts" # - # This method also accepts a block meaning that all queries inside the block will + # This method also accepts a block. All queries inside the block will # not use the default_scope: # # Post.unscoped { # Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10" # } # - # It is recommended to use block form of unscoped because chaining unscoped with <tt>scope</tt> - # does not work. Assuming that <tt>published</tt> is a <tt>scope</tt> following two statements are same. + # It is recommended to use the block form of unscoped because chaining + # unscoped with <tt>scope</tt> does not work. Assuming that + # <tt>published</tt> is a <tt>scope</tt>, the following two statements + # are equal: the default_scope is applied on both. # - # Post.unscoped.published - # Post.published + # Post.unscoped.published + # Post.published def unscoped #:nodoc: block_given? ? relation.scoping { yield } : relation end diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb index 838aa8fb1e..0c35adc11d 100644 --- a/activerecord/lib/active_record/version.rb +++ b/activerecord/lib/active_record/version.rb @@ -1,7 +1,7 @@ module ActiveRecord module VERSION #:nodoc: - MAJOR = 3 - MINOR = 2 + MAJOR = 4 + MINOR = 0 TINY = 0 PRE = "beta" |