提交 945dd920 编写于 作者: M Marcel Molina

Don't raise an exception when there are more keys than there are named bind...

Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3382 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 a5708b4c
*SVN*
* Don't raise an exception when there are more keys than there are named bind variables when sanitizing conditions. [Marcel Molina Jr.]
* Multiple enhancements and adjustments to DB2 adaptor. #3377 [contact@maik-schmidt.de]
* Sanitize scoped conditions. [Marcel Molina Jr.]
......
......@@ -1140,7 +1140,6 @@ def replace_bind_variables(statement, values)
end
def replace_named_bind_variables(statement, bind_vars)
raise_if_bind_arity_mismatch(statement, statement.scan(/:(\w+)/).uniq.size, bind_vars.size)
statement.gsub(/:(\w+)/) do
match = $1.to_sym
if bind_vars.include?(match)
......
......@@ -74,12 +74,6 @@ def test_named_bind_variables
assert_nil Company.find_first(["name = :name", { :name => "37signals!" }])
assert_nil Company.find_first(["name = :name", { :name => "37signals!' OR 1=1" }])
assert_kind_of Time, Topic.find_first(["id = :id", { :id => 1 }]).written_on
assert_raises(ActiveRecord::PreparedStatementInvalid) {
Company.find_first(["id=:id and name=:name", { :id=>3 }])
}
assert_raises(ActiveRecord::PreparedStatementInvalid) {
Company.find_first(["id=:id", { :id=>3, :name=>"37signals!" }])
}
end
def test_count
......
......@@ -157,22 +157,6 @@ def test_named_bind_variables
assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!" }])
assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!' OR 1=1" }])
assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on
assert_raises(ActiveRecord::PreparedStatementInvalid) {
Company.find(:first, :conditions => ["id=:id and name=:name", { :id=>3 }])
}
assert_raises(ActiveRecord::PreparedStatementInvalid) {
Company.find(:first, :conditions => ["id=:id", { :id=>3, :name=>"37signals!" }])
}
end
def test_named_bind_arity
assert_nothing_raised { bind '', {} }
assert_raises(ActiveRecord::PreparedStatementInvalid) { bind '', :a => 1 }
assert_raises(ActiveRecord::PreparedStatementInvalid) { bind ':a', {} } # ' ruby-mode
assert_nothing_raised { bind ':a', :a => 1 } # ' ruby-mode
assert_raises(ActiveRecord::PreparedStatementInvalid) { bind ':a', :a => 1, :b => 2 } # ' ruby-mode
assert_nothing_raised { bind ':a :a', :a => 1 } # ' ruby-mode
assert_raises(ActiveRecord::PreparedStatementInvalid) { bind ':a :a', :a => 1, :b => 2 } # ' ruby-mode
end
def test_bind_enumerable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册