Skip to content

Commit

Permalink
Remedy for SELECT COUNT(DISTINCT *) FROM ...
Browse files Browse the repository at this point in the history
For whatever reason using #joins and #select wreaks havoc
when calling #count.
  • Loading branch information
mlt committed May 16, 2018
1 parent 459e44d commit 0023d1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tabulatr/data/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def data_for_table(params, locals: {}, default_order: nil, controller: nil, &blo
@default_order = default_order

# count
total = @relation.count
total = @relation.count(:all)

# prepare the query
apply_filters(filter_params params)
Expand Down
2 changes: 1 addition & 1 deletion lib/tabulatr/data/pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def apply_pagination(offset: 0, pagesize: nil)
end

def compute_pagination(page, pagesize)
count = @relation.count
count = @relation.count(:all)
count = count.count if count.is_a?(Hash)
page ||= 1
pagesize, page = pagesize.to_i, page.to_i
Expand Down

0 comments on commit 0023d1a

Please sign in to comment.