File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
lib/active_record/connection_adapters/sqlserver/core_ext Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,25 @@ module ConnectionAdapters
66 module SQLServer
77 module CoreExt
88 module Calculations
9+
10+ # Same as original except we don't perform PostgreSQL hack that removes ordering.
11+ def calculate ( operation , column_name )
12+ if has_include? ( column_name )
13+ relation = apply_join_dependency
14+
15+ if operation . to_s . downcase == "count"
16+ unless distinct_value || distinct_select? ( column_name || select_for_count )
17+ relation . distinct!
18+ relation . select_values = [ klass . primary_key || table [ Arel . star ] ]
19+ end
20+ end
21+
22+ relation . calculate ( operation , column_name )
23+ else
24+ perform_calculation ( operation , column_name )
25+ end
26+ end
27+
928 private
1029
1130 def build_count_subquery ( relation , column_name , distinct )
You can’t perform that action at this time.
0 commit comments