Permalink
Browse files

Merge pull request #11439 from ernie/only-scan-strings-for-nodes

Blacklist->whitelist for reference scans in order!
  • Loading branch information...
2 parents 648afea + e2d8250 commit 5979bc9e11d68e11458a27037edffaa368990f27 @senny senny committed Jul 14, 2013
@@ -280,7 +280,7 @@ def order!(*args) # :nodoc:
args.flatten!
validate_order_args args
- references = args.reject { |arg| Arel::Node === arg }
+ references = args.grep(String)
references.map! { |arg| arg =~ /^([a-zA-Z]\w*)\.(\w+)/ && $1 }.compact!
references!(references) if references.any?
@@ -227,6 +227,13 @@ def relation
assert_equal ['"posts".name ASC'], relation.order_values
end
+ test "#order! on non-string does not attempt regexp match for references" do
+ obj = Object.new
+ obj.expects(:=~).never
+ assert relation.order!(obj)
+ assert_equal [obj], relation.order_values
+ end
+
test '#references!' do
assert relation.references!(:foo).equal?(relation)
assert relation.references_values.include?('foo')

0 comments on commit 5979bc9

Please sign in to comment.