Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

reorder removed in favor of except(:order).order

  • Loading branch information...
commit e0b76d6151821527f16b3f163abde3ebea1b2a50 1 parent 21a92b8
@spastorino spastorino authored
View
2  activerecord/lib/active_record/base.rb
@@ -423,7 +423,7 @@ class Base
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
View
11 activerecord/lib/active_record/relation/query_methods.rb
@@ -6,7 +6,7 @@ module QueryMethods
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 @@ def order(*args)
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
View
11 activerecord/lib/active_record/relation/spawn_methods.rb
@@ -19,20 +19,11 @@ def merge(r)
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
View
10 activerecord/test/cases/relation_scoping_test.rb
@@ -384,18 +384,12 @@ def test_named_scope_overwrites_default
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
View
6 activerecord/test/cases/relations_test.rb
@@ -135,12 +135,6 @@ def test_finding_with_order_concatenated
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
View
1  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
Please sign in to comment.
Something went wrong with that request. Please try again.