From 4182b6fb8f7f96b2dd34eb670fc7821a38718de1 Mon Sep 17 00:00:00 2001 From: Andrew Kvalheim Date: Sat, 4 Apr 2020 10:06:20 -0700 Subject: [PATCH] Fix bug in UserDatatable query affecting PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: $ docker-compose run --rm osem bundle exec rspec ./spec/datatables/user_datatable_spec.rb:97 … ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "users.id" must appear in the GROUP BY clause or be used in an aggregate function --- app/datatables/user_datatable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index 3b3e1197..b97eb404 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -49,12 +49,12 @@ class UserDatatable < AjaxDatatablesRails::Base # Workaround for jbox-web/ajax-datatables-rails#293 def records_total_count - fetch_records.unscope(:group).count(:all) + fetch_records.unscope(:group, :select).count(:all) end # Workaround for jbox-web/ajax-datatables-rails#293 def records_filtered_count - filter_records(fetch_records).unscope(:group).count(:all) + filter_records(fetch_records).unscope(:group, :select).count(:all) end # ==== These methods represent the basic operations to perform on records