提交 8352287c 编写于 作者: J Jeremy Kemper

Fix edge case with colons in times interpreted as bind variables by requiring...

Fix edge case with colons in times interpreted as bind variables by requiring that bind vars start with a letter. Closes #10519 [matrix9180]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8936 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 33736bc1
......@@ -1924,7 +1924,7 @@ def replace_bind_variables(statement, values) #:nodoc:
end
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
statement.gsub(/:(\w+)/) do
statement.gsub(/:([a-zA-Z]\w*)/) do
match = $1.to_sym
if bind_vars.include?(match)
quote_bound_value(bind_vars[match])
......
......@@ -339,6 +339,8 @@ def test_bind_arity
def test_named_bind_variables
assert_equal '1', bind(':a', :a => 1) # ' ruby-mode
assert_equal '1 1', bind(':a :a', :a => 1) # ' ruby-mode
assert_nothing_raised { bind("'+00:00'", :foo => "bar") }
assert_kind_of Firm, Company.find(:first, :conditions => ["name = :name", { :name => "37signals" }])
assert_nil Company.find(:first, :conditions => ["name = :name", { :name => "37signals!" }])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册