diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 6 | ||||
-rwxr-xr-x | activerecord/test/associations_test.rb | 1 |
3 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 0d0ae92682..6d74ebc70f 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Correctly quote id list for limited eager loading. #7482 [tmacedo] + * Fixed that using version-targetted migrates would fail on loggers other than the default one #7430 [valeksenko] * Fixed rename_column for SQLite when using symbols for the column names #8616 [drodriguez] diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index a508a9c94d..cb821ba7f0 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1256,12 +1256,14 @@ module ActiveRecord throw :invalid_query end end - + def select_limited_ids_list(options, join_dependency) + pk = columns_hash[primary_key] + connection.select_all( construct_finder_sql_for_association_limiting(options, join_dependency), "#{name} Load IDs For Limited Eager Loading" - ).collect { |row| connection.quote(row[primary_key]) }.join(", ") + ).collect { |row| connection.quote(row[primary_key], pk) }.join(", ") end def construct_finder_sql_for_association_limiting(options, join_dependency) diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 222cb5dbca..8cb3c16a66 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1846,6 +1846,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase join_base = ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase.new(Project) join_dep = ActiveRecord::Associations::ClassMethods::JoinDependency.new(join_base, :developers, nil) projects = Project.send(:select_limited_ids_list, {:order => 'developers.created_at'}, join_dep) + assert !projects.include?("'"), projects assert_equal %w(1 2), projects.scan(/\d/).sort end |