Permalink
Browse files

Don't raise an exception when there are more keys than there are name…

…d bind variables when sanitizing conditions.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3382 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a5708b4 commit 945dd920ab0954acdbc9b3317145b267a9638a50 Marcel Molina committed Jan 5, 2006
View
@@ -1,5 +1,7 @@
*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

0 comments on commit 945dd92

Please sign in to comment.