This project is read-only.


Orchard Hql API Not Returning Distinct Values



I recently had an issue where the hql queries that I was performing through the Orchard API was not returning distinct values. I saw that the Count and Splice functions have .SetResultTransformer(new DistinctRootEntityResultTransformer()); which is suppose to return distinct results, but this was not working for me.

One thing to note is that I joined a non contentpart table in this query (not sure if this matters).

The only way I could solve this issue was by changing the first few lines of the ToHql method in DefaultHqlQuery.cs from:
            if (count) {
                sb.Append("select count(civ) ").AppendLine();
            else {
                sb.Append("select civ ").AppendLine();
            if (count) {
                sb.Append("select count(distinct civ.Id) ").AppendLine();
            else {
                sb.Append("select distinct civ.Id, civ ").AppendLine();
Does anyone see any issues with this? Is there any other way to do this?

Thanks in advance.


sebastienros wrote May 23, 2013 at 7:15 PM

Fixed in changeset 5cbfb9b6cd21

Skelet0r67 wrote May 24, 2013 at 12:51 AM

I can't seem to find that commit. Which branch is it under?

Skelet0r67 wrote May 24, 2013 at 7:43 PM

I see it now, thanks.

sfmskywalker wrote Aug 7, 2013 at 6:02 AM

Fixed in changeset a094efac2d8394a4e89d3b96a56864b26f159e95