<div dir="ltr">Using postgres 8.3.1 and RT 3.8.2<br><br>Hi I have a very odd problem - I am working on a develpment branch of our software in which the sort by requestors or by custom fields in the search results table stopped working. <br>
<br>I researched it for a while and i compared it with an older version of our software, extracting the SQL query after OrderByCols call and I saw this query:<br><br>SELECT main.* <br>FROM ( SELECT <a href="http://main.id">main.id</a> <br>
FROM Tickets main <br> JOIN Groups Groups_1 <br> ON ( Groups_1.Domain = 'RT::Ticket-Role' ) AND <br> ( Groups_1.Type = 'Requestor' ) AND <br>
( Groups_1.Instance = <a href="http://main.id">main.id</a> ) <br> LEFT JOIN CachedGroupMembers CachedGroupMembers_2 <br> ON ( CachedGroupMembers_2.GroupId != CachedGroupMembers_2.MemberId ) AND <br>
( CachedGroupMembers_2.GroupId = Groups_1.id ) <br> LEFT JOIN Users Users_3 <br> ON ( Users_3.id = CachedGroupMembers_2.MemberId ) <br> WHERE (main.Status != 'deleted') AND <br>
(main.Queue = '1' AND ( main.Queue = '1' ) ) AND <br> (main.Type = 'ticket') AND <br> (main.EffectiveId = <a href="http://main.id">main.id</a>) <br>
GROUP BY <a href="http://main.id">main.id</a> <br> ORDER BY MIN(Users_3.EmailAddress) ASC <br> ) distinctquery, Tickets main <br>WHERE (<a href="http://main.id">main.id</a> = <a href="http://distinctquery.id">distinctquery.id</a>)<br>
<br>trying this query on the older version worked fine (and when I make the order DESC it change the results) while on the devel version it doesn't matter it just won't order it for me.<br><br>I suspected that the problem is that the order is inside the subquery and AFAIK (and asked in postgresql IRC) join doesn't keep the order.<br>
I wonder if it worked only by accident or if I am missing something <br></div>