Skip to content

Commit

Permalink
[#4236] datastore_search: distinct=true total fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi authored and tino097 committed Nov 29, 2018
1 parent 102b710 commit dd4af37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ckanext/datastore/backend/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,11 @@ def search_data(context, data_dict):
_insert_links(data_dict, limit, offset)

if data_dict.get('include_total', True):
count_sql_string = u'''SELECT {distinct} count(*)
FROM "{resource}" {ts_query} {where};'''.format(
count_sql_string = u'''SELECT count(*) FROM (
SELECT {distinct} {select}
FROM "{resource}" {ts_query} {where}) as t;'''.format(
distinct=distinct,
select=select_columns,
resource=resource_id,
ts_query=ts_query,
where=where_clause)
Expand Down

0 comments on commit dd4af37

Please sign in to comment.