diff options
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d52695d162..505ebea9f6 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1197,6 +1197,7 @@ module ActiveRecord sql = "SELECT " if is_distinct ordered_columns = options[:order].to_s.split(',').collect! { |s| s.split.first } + options[:order] = "#{table_name}.#{primary_key}, #{options[:order]}" if options[:order] && connection.requires_order_columns_in_distinct_clause? sql << connection.distinct("#{table_name}.#{primary_key}", ordered_columns) else sql << primary_key |