modxcms / Collections

An Extra for MODX Revolution that provides for Resource Collections managed by CollectionContainer Resources
GNU General Public License v2.0
53 stars 37 forks source link

Fetch distinct resources #363

Closed pbowyer closed 1 year ago

pbowyer commented 1 year ago

When using the search feature in Tagger on a site using Tagger, the wrong number of resources are returned.

The COUNT query is correct because it already looks at distinct resources, but the data query doesn't. This means it fetches one row per Tagger tag linked to the resource and so the wrong number of results are shown.

In my test case the query should have returned 9 resources. Instead it returned 3 because the first and second resources had 1 tag each, and the third resource 8 tags. With the LIMIT 10 on results, these 10 rows were all that were retrieved, and there is no pagination because there should only be 9 resources.

This patch fixes the problem and returns distinct rows.