mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Reverting e170014113
(Change behaviour with empty hash in where clause)
This commit is contained in:
parent
b5645d0273
commit
29f3a036e7
3 changed files with 3 additions and 12 deletions
|
@ -1,10 +1,5 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* Raise `ArgumentError` instead of generating invalid SQL when empty hash is
|
||||
used in where clause value.
|
||||
|
||||
*Roberto Miranda*
|
||||
|
||||
* Quote numeric values being compared to non-numeric columns. Otherwise,
|
||||
in some database, the string column values will be coerced to a numeric
|
||||
allowing 0, 0.0 or false to match any string starting with a non-digit.
|
||||
|
|
|
@ -8,7 +8,7 @@ module ActiveRecord
|
|||
|
||||
if value.is_a?(Hash)
|
||||
if value.empty?
|
||||
raise ArgumentError, "Condition value in SQL clause can't be an empty hash"
|
||||
queries << '1 = 2'
|
||||
else
|
||||
table = Arel::Table.new(column, default_table.engine)
|
||||
association = klass.reflect_on_association(column.to_sym)
|
||||
|
|
|
@ -92,9 +92,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def test_where_with_table_name_and_empty_hash
|
||||
assert_raises(ArgumentError) do
|
||||
Post.where(:posts => {})
|
||||
end
|
||||
assert_equal 0, Post.where(:posts => {}).count
|
||||
end
|
||||
|
||||
def test_where_with_table_name_and_empty_array
|
||||
|
@ -102,9 +100,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def test_where_with_empty_hash_and_no_foreign_key
|
||||
assert_raises(ArgumentError) do
|
||||
Edge.where(:sink => {}).count
|
||||
end
|
||||
assert_equal 0, Edge.where(:sink => {}).count
|
||||
end
|
||||
|
||||
def test_where_with_blank_conditions
|
||||
|
|
Loading…
Reference in a new issue