diff options
Diffstat (limited to 'activerecord')
5 files changed, 12 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb index 7a6386bd7d..e25198fa0d 100644 --- a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb @@ -294,8 +294,10 @@ module ActiveRecord # 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? diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index fdfa887905..e4c9c411b3 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -214,6 +214,8 @@ begin 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 diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb index f4913f72fd..658330cf53 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb @@ -333,6 +333,8 @@ module ActiveRecord 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) diff --git a/activerecord/lib/active_record/connection_adapters/sybase_adapter.rb b/activerecord/lib/active_record/connection_adapters/sybase_adapter.rb index 3272e6d598..e464fc56ad 100644 --- a/activerecord/lib/active_record/connection_adapters/sybase_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sybase_adapter.rb @@ -273,6 +273,8 @@ module ActiveRecord 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) diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index e04d02d9cb..1cd16c7cd8 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -387,13 +387,9 @@ class FinderTest < Test::Unit::TestCase 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 |