Fix bug in UserDatatable query affecting PostgreSQL

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
This commit is contained in:
Andrew Kvalheim 2020-04-04 10:06:20 -07:00
parent d3e73b103f
commit 4182b6fb8f

View file

@ -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