aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-10-10 21:32:01 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2010-10-11 11:54:46 -0200
commite0b76d6151821527f16b3f163abde3ebea1b2a50 (patch)
treec303ea44988442d7dfbe021586978bba2d2de22a
parent21a92b8d01eed34a6b26adb51139f1c40467409e (diff)
downloadrails-e0b76d6151821527f16b3f163abde3ebea1b2a50.tar.gz
rails-e0b76d6151821527f16b3f163abde3ebea1b2a50.tar.bz2
rails-e0b76d6151821527f16b3f163abde3ebea1b2a50.zip
reorder removed in favor of except(:order).order
-rw-r--r--activerecord/lib/active_record/base.rb2
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb11
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb11
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb10
-rw-r--r--activerecord/test/cases/relations_test.rb6
-rw-r--r--activerecord/test/models/developer.rb1
6 files changed, 5 insertions, 36 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ff6be4ff19..78b3507dd9 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -423,7 +423,7 @@ module ActiveRecord #:nodoc:
class << self # Class methods
delegate :find, :first, :last, :all, :destroy, :destroy_all, :exists?, :delete, :delete_all, :update, :update_all, :to => :scoped
delegate :find_each, :find_in_batches, :to => :scoped
- delegate :select, :group, :order, :reorder, :limit, :offset, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :create_with, :to => :scoped
+ delegate :select, :group, :order, :except, :limit, :offset, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :create_with, :to => :scoped
delegate :count, :average, :minimum, :maximum, :sum, :calculate, :to => :scoped
# Executes a custom SQL query against your database and returns all the results. The results will
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 001207514d..a5dc051c6e 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -6,7 +6,7 @@ module ActiveRecord
extend ActiveSupport::Concern
attr_accessor :includes_values, :eager_load_values, :preload_values,
- :select_values, :group_values, :order_values, :reorder_flag, :joins_values, :where_values, :having_values,
+ :select_values, :group_values, :order_values, :joins_values, :where_values, :having_values,
:limit_value, :offset_value, :lock_value, :readonly_value, :create_with_value, :from_value
def includes(*args)
@@ -53,15 +53,6 @@ module ActiveRecord
relation
end
- def reorder(*args)
- relation = clone
- unless args.blank?
- relation.order_values = args
- relation.reorder_flag = true
- end
- relation
- end
-
def joins(*args)
relation = clone
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 9ecdb99bee..dcddc3dac4 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -19,20 +19,11 @@ module ActiveRecord
end
end
- (Relation::MULTI_VALUE_METHODS - [:joins, :where, :order]).each do |method|
+ (Relation::MULTI_VALUE_METHODS - [:joins, :where]).each do |method|
value = r.send(:"#{method}_values")
merged_relation.send(:"#{method}_values=", merged_relation.send(:"#{method}_values") + value) if value.present?
end
- order_value = r.order_values
- if order_value.present?
- if r.reorder_flag
- merged_relation.order_values = order_value
- else
- merged_relation.order_values = merged_relation.order_values + order_value
- end
- end
-
merged_relation = merged_relation.joins(r.joins_values)
merged_wheres = @where_values
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 090e6c8bc9..64365c1d75 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -384,18 +384,12 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal expected, received
end
- def test_reorder_overrides_default_scope_order
+ def test_except_and_order_overrides_default_scope_order
expected = Developer.order('name DESC').collect { |dev| dev.name }
- received = DeveloperOrderedBySalary.reorder('name DESC').collect { |dev| dev.name }
+ received = DeveloperOrderedBySalary.except(:order).order('name DESC').collect { |dev| dev.name }
assert_equal expected, received
end
- def test_reordered_scope_overrides_default_scope_order
- not_expected = DeveloperOrderedBySalary.first # Jamis -> name DESC
- received = DeveloperOrderedBySalary.reordered_by_name.first # David -> name
- assert not_expected.id != received.id
- end
-
def test_nested_exclusive_scope
expected = Developer.find(:all, :limit => 100).collect { |dev| dev.salary }
received = DeveloperOrderedBySalary.send(:with_exclusive_scope, :find => { :limit => 100 }) do
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index d642aeed8b..222819cbe5 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -135,12 +135,6 @@ class RelationTest < ActiveRecord::TestCase
assert_equal topics(:fourth).title, topics.first.title
end
- def test_finding_with_reorder
- topics = Topic.order('author_name').order('title').reorder('id')
- assert_equal 4, topics.to_a.size
- assert_equal topics(:first).title, topics.first.title
- end
-
def test_finding_with_order_and_take
entrants = Entrant.order("id ASC").limit(2).to_a
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index 947583af76..32d060cf09 100644
--- a/activerecord/test/models/developer.rb
+++ b/activerecord/test/models/developer.rb
@@ -88,7 +88,6 @@ class DeveloperOrderedBySalary < ActiveRecord::Base
self.table_name = 'developers'
default_scope :order => 'salary DESC'
scope :by_name, order('name DESC')
- scope :reordered_by_name, reorder('name')
def self.all_ordered_by_name
with_scope(:find => { :order => 'name DESC' }) do