提交 74b7bfa6 编写于 作者: J Jeremy Kemper

Mind the order of things.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4393 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 97f4a5aa
......@@ -294,8 +294,10 @@ def native_database_types #:nodoc
# Quotes the column value to help prevent
# {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection].
def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
retvalue = "<INVALID>"
puts "quote(#{value.inspect}(#{value.class}),#{column.type.inspect})" if FB_TRACE
# If a column was passed in, use column type information
unless value.nil?
......
......@@ -214,6 +214,8 @@ def quote_string(string) #:nodoc:
end
def quote(value, column = nil) #:nodoc:
return value.quoted_id if value.respond_to?(:quoted_id)
if column && [:text, :binary].include?(column.type)
%Q{empty_#{ column.sql_type rescue 'blob' }()}
else
......
......@@ -333,6 +333,8 @@ def rollback_db_transaction
end
def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
case value
when String
if column && column.type == :binary && column.class.respond_to?(:string_to_binary)
......
......@@ -273,6 +273,8 @@ def quoted_false
end
def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
case value
when String
if column && column.type == :binary && column.class.respond_to?(:string_to_binary)
......
......@@ -387,13 +387,9 @@ def test_find_by_empty_in_condition
end
def test_find_by_records
p1, p2 = Post.find(1, 2)
assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]]).sort_by { |p| p.id }
end
def test_find_by_records_and_ids
p1, p2 = Post.find(1, 2)
assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2.id]]).sort_by { |p| p.id }
p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc')
assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]], :order => 'id asc')
assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2.id]], :order => 'id asc')
end
def test_select_value
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册