File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
lib/active_record/connection_adapters/sqlserver Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -347,12 +347,16 @@ def add_timestamps(table_name, **options)
347347
348348 def columns_for_distinct ( columns , orders )
349349 order_columns = orders . reject ( &:blank? ) . map { |s |
350- s = s . to_sql unless s . is_a? ( String )
350+ s = visitor . compile ( s ) unless s . is_a? ( String )
351351 s . gsub ( /\s +(?:ASC|DESC)\b /i , "" )
352352 . gsub ( /\s +NULLS\s +(?:FIRST|LAST)\b /i , "" )
353- } . reject ( &:blank? ) . map . with_index { |column , i | "#{ column } AS alias_#{ i } " }
353+ }
354+ . reject ( &:blank? )
355+ . reject { |s | columns . include? ( s ) }
354356
355- ( order_columns << super ) . join ( ", " )
357+ order_columns_aliased = order_columns . map . with_index { |column , i | "#{ column } AS alias_#{ i } " }
358+
359+ ( order_columns_aliased << super ) . join ( ", " )
356360 end
357361
358362 def update_table_definition ( table_name , base )
You can’t perform that action at this time.
0 commit comments