Skip to content

Commit fae4540

Browse files
committed
Remove order from count subquery
1 parent 9f4f3f5 commit fae4540

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def build_count_subquery(relation, column_name, distinct)
1818
end
1919
]
2020

21+
relation = relation.unscope(:order)
2122
subquery = relation.arel.as(Arel.sql("subquery_for_count"))
2223
select_value = operation_over_aggregate_column(column_alias || Arel.star, "count", false)
2324

@@ -31,8 +32,8 @@ def build_count_subquery(relation, column_name, distinct)
3132

3233
ActiveSupport.on_load(:active_record) do
3334
if ActiveRecord::VERSION::MAJOR == 5 &&
34-
ActiveRecord::VERSION::MINOR == 1 &&
35-
ActiveRecord::VERSION::TINY >= 4
35+
ActiveRecord::VERSION::MINOR == 2 &&
36+
ActiveRecord::VERSION::TINY >= 0
3637
mod = ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::Calculations
3738
ActiveRecord::Relation.prepend(mod)
3839
end

0 commit comments

Comments
 (0)