From 78c2079a2cb3b10c43c10945890523a1c645bed6 Mon Sep 17 00:00:00 2001 From: Aidan Haran Date: Fri, 27 Sep 2024 20:24:38 +0100 Subject: [PATCH] Keep ordering in count subquery (#1227) --- .../sqlserver/core_ext/calculations.rb | 29 ------------------- .../connection_adapters/sqlserver_adapter.rb | 2 -- 2 files changed, 31 deletions(-) delete mode 100644 lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb diff --git a/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb b/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb deleted file mode 100644 index 5fafea101..000000000 --- a/lib/active_record/connection_adapters/sqlserver/core_ext/calculations.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require "active_record/relation" -require "active_record/version" - -module ActiveRecord - module ConnectionAdapters - module SQLServer - module CoreExt - module Calculations - - private - - def build_count_subquery(relation, column_name, distinct) - model.with_connection do |connection| - relation = relation.unscope(:order) if connection.sqlserver? - super(relation, column_name, distinct) - end - end - end - end - end - end -end - -ActiveSupport.on_load(:active_record) do - mod = ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::Calculations - ActiveRecord::Relation.include(mod) -end diff --git a/lib/active_record/connection_adapters/sqlserver_adapter.rb b/lib/active_record/connection_adapters/sqlserver_adapter.rb index dacf11cdc..314eacce1 100644 --- a/lib/active_record/connection_adapters/sqlserver_adapter.rb +++ b/lib/active_record/connection_adapters/sqlserver_adapter.rb @@ -4,9 +4,7 @@ require "base64" require "active_record" require "arel_sqlserver" -require "active_record/connection_adapters/abstract_adapter" require "active_record/connection_adapters/sqlserver/core_ext/active_record" -require "active_record/connection_adapters/sqlserver/core_ext/calculations" require "active_record/connection_adapters/sqlserver/core_ext/explain" require "active_record/connection_adapters/sqlserver/core_ext/explain_subscriber" require "active_record/connection_adapters/sqlserver/core_ext/attribute_methods"