diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index adde221477..8cb6bd02ac 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1266,7 +1266,7 @@ module ActiveRecord def construct_finder_sql_for_association_limiting(options, join_dependency) scope = scope(:find) - is_distinct = include_eager_conditions?(options) || include_eager_order?(options) + is_distinct = !options[:joins].blank? || include_eager_conditions?(options) || include_eager_order?(options) sql = "SELECT " if is_distinct sql << connection.distinct("#{table_name}.#{primary_key}", options[:order]) |