Forum Discussion

PerBonomi's avatar
9 years ago

ORDER BY doesn't sort

Hi everyone. I've been using Liql for quite some time now and it never presented an issue when sorting.

Now, however, when I try the below queries they both sort the same way, descending, regardless of whether I choose ORDER BY ASC or DESC.

 

Has anyone come across this phenomenon and found a fix? Perhaps I missed a memo somewhere?

 

Ascending:<br/>
<#assign query = restadmin("2.0","/search?q=" + "SELECT login FROM users WHERE followers.id = '${user.id}' ORDER BY login ASC LIMIT 10"?url) />
<#list query.data.items as q>
${q.login}<br/>
</#list>
<br/>Descending:<br/>
<#assign query = restadmin("2.0","/search?q=" + "SELECT login FROM users WHERE followers.id = '${user.id}' ORDER BY login DESC LIMIT 10"?url) />
<#list query.data.items as q>
${q.login}<br/>
</#list>
  • DougS's avatar
    DougS
    Khoros Oracle

    Thanks for reporting this. We were able to reproduce the bug as far back as 15.12 (don't have an older site to test on atm) and we've filed a bug report in our issue tracking system to fix the issue.

     

    I've noticed that if you don't constrain the query by followers.id, then it sorts fine. A also tried adding the WHERE kudos.sum(weight) constraint and it sorted fine with that as well. We'll do some testing to see if we can find other constraints that aren't sorting correctly as well.

     

    -Doug

    • Thanks for confirming DougS. I tried adding additional constraints to my query to try and trick it into sorting properly. Unfortunately, if you use followers.id you cannot add additional ones.

      Guess I'll have to wait with publishing these components until the issue is fixed.

      • PerBonomi's avatar
        PerBonomi
        Boss

        Looks like this is still happening btw. Both of these give me results in descending order:

         

        <#assign query_follow = restadmin("2.0","/search?q=" + "SELECT login FROM users WHERE followers.id = '${user.id}' ORDER BY login ASC LIMIT 10"?url) />
        <#list query_follow.data.items as q>
        	${q.login}<br/>
        </#list>
        <br/>
        <#assign query_follow = restadmin("2.0","/search?q=" + "SELECT login FROM users WHERE followers.id = '${user.id}' ORDER BY login DESC LIMIT 10"?url) />
        <#list query_follow.data.items as q>
        	${q.login}<br/>
        </#list>