1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Mind the order of things.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4393 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2006-06-01 02:04:35 +00:00
parent 97f4a5aa14
commit 74b7bfa6d2
5 changed files with 12 additions and 8 deletions

View file

@ -294,6 +294,8 @@ module ActiveRecord
# Quotes the column value to help prevent # Quotes the column value to help prevent
# {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection]. # {SQL injection attacks}[http://en.wikipedia.org/wiki/SQL_injection].
def quote(value, column = nil) def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
retvalue = "<INVALID>" retvalue = "<INVALID>"
puts "quote(#{value.inspect}(#{value.class}),#{column.type.inspect})" if FB_TRACE puts "quote(#{value.inspect}(#{value.class}),#{column.type.inspect})" if FB_TRACE

View file

@ -214,6 +214,8 @@ begin
end end
def quote(value, column = nil) #:nodoc: def quote(value, column = nil) #:nodoc:
return value.quoted_id if value.respond_to?(:quoted_id)
if column && [:text, :binary].include?(column.type) if column && [:text, :binary].include?(column.type)
%Q{empty_#{ column.sql_type rescue 'blob' }()} %Q{empty_#{ column.sql_type rescue 'blob' }()}
else else

View file

@ -333,6 +333,8 @@ module ActiveRecord
end end
def quote(value, column = nil) def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
case value case value
when String when String
if column && column.type == :binary && column.class.respond_to?(:string_to_binary) if column && column.type == :binary && column.class.respond_to?(:string_to_binary)

View file

@ -273,6 +273,8 @@ module ActiveRecord
end end
def quote(value, column = nil) def quote(value, column = nil)
return value.quoted_id if value.respond_to?(:quoted_id)
case value case value
when String when String
if column && column.type == :binary && column.class.respond_to?(:string_to_binary) if column && column.type == :binary && column.class.respond_to?(:string_to_binary)

View file

@ -387,13 +387,9 @@ class FinderTest < Test::Unit::TestCase
end end
def test_find_by_records def test_find_by_records
p1, p2 = Post.find(1, 2) p1, p2 = Post.find(:all, :limit => 2, :order => 'id asc')
assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]]).sort_by { |p| p.id } assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2]], :order => 'id asc')
end assert_equal [p1, p2], Post.find(:all, :conditions => ['id in (?)', [p1, p2.id]], :order => 'id asc')
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 }
end end
def test_select_value def test_select_value