Permalink
Browse files

Merge pull request #13859 from huoxito/let-it-go

Let `unscope` ignore non Arel scope.where_values
  • Loading branch information...
2 parents 27aedee + abc19c3 commit f64c50a092394917ad9a79abc563aa2bef22ce94 @rafaelfranca rafaelfranca committed Jan 30, 2014
@@ -883,8 +883,6 @@ def where_unscoping(target_value)
when Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual
subrelation = (rel.left.kind_of?(Arel::Attributes::Attribute) ? rel.left : rel.right)
subrelation.name == target_value
- else
- raise "unscope(where: #{target_value.inspect}) failed: unscoping #{rel.class} \"#{rel}\" is unimplemented."
end
end
@@ -149,6 +149,16 @@ def test_unscope_multiple_where_clauses
assert_equal expected, received
end
+ def test_unscope_string_where_clauses_involved
+ dev_relation = Developer.order('salary DESC').where("created_at > ?", 1.year.ago)
+ expected = dev_relation.collect { |dev| dev.name }
+
+ dev_ordered_relation = DeveloperOrderedBySalary.where(name: 'Jamis').where("created_at > ?", 1.year.ago)
+ received = dev_ordered_relation.unscope(where: [:name]).collect { |dev| dev.name }
+
+ assert_equal expected, received
+ end
+
def test_unscope_with_grouping_attributes
expected = Developer.order('salary DESC').collect { |dev| dev.name }
received = DeveloperOrderedBySalary.group(:name).unscope(:group).collect { |dev| dev.name }

0 comments on commit f64c50a

Please sign in to comment.