diff --git a/lib/active_record/connection_adapters/clickhouse_adapter.rb b/lib/active_record/connection_adapters/clickhouse_adapter.rb index 739c452a..554d2ce7 100644 --- a/lib/active_record/connection_adapters/clickhouse_adapter.rb +++ b/lib/active_record/connection_adapters/clickhouse_adapter.rb @@ -30,13 +30,13 @@ def clickhouse_connection(config) end end - module QueryMethods + class Relation # Replace for only ClickhouseAdapter def reverse_order! orders = order_values.uniq orders.reject!(&:blank?) - if self.connection.is_a?(ConnectionAdapters::ClickhouseAdapter) && orders.empty? + if self.connection.is_a?(ConnectionAdapters::ClickhouseAdapter) && orders.empty? && !primary_key self.order_values = %w(date created_at).select {|c| column_names.include?(c) }.map{|c| arel_attribute(c).desc } else self.order_values = reverse_sql_order(orders) diff --git a/lib/clickhouse-activerecord/version.rb b/lib/clickhouse-activerecord/version.rb index 89b70ce7..dd7f9e9e 100644 --- a/lib/clickhouse-activerecord/version.rb +++ b/lib/clickhouse-activerecord/version.rb @@ -1,3 +1,3 @@ module ClickhouseActiverecord - VERSION = '0.3.7' + VERSION = '0.3.8' end