ObjectCustomFields are not sorted at all

Hi,

When creating or looking at a request, the ObjectCustomFields are not
sorted at all. This has become a big problem for us, since we are using RT
to create a form that a business partner shall use to enter orders.
Browsing the archives here, this seems to be a problem, and one that is
hard to solve. Dunno if it has been fixed, though, but it fails for me.

The SQL in question is this:

SELECT main.* FROM ( SELECT main.id FROM CustomFields main ,
ObjectCustomFields ObjectCustomFields_1 WHERE
((ObjectCustomFields_1.ObjectId = ‘12’) OR (ObjectCustomFields_1.ObjectId
= ‘0’)) AND ((main.Disabled = ‘0’)) AND
((main.LookupType = ‘RT::Queue-RT::Ticket’)) AND ((main.id =
ObjectCustomFields_1.CustomField)) GROUP BY main.id ORDER BY
min(ObjectCustomFields_1.ObjectId) ASC,
min(ObjectCustomFields_1.SortOrder) ASC ) distinctquery, CustomFields main
WHERE
(main.id = distinctquery.id)

Ths sorting is done in the inner select, which is ignored in the outer.
This SQL produces the expected result:

SELECT main.* FROM ( SELECT main.id , ObjectCustomFields_1.sortorder FROM
CustomFields main , ObjectCustomFields ObjectCustomFields_1 WHERE
((ObjectCustomFields_1.ObjectId = ‘12’) OR (ObjectCustomFields_1.ObjectId
= ‘0’)) AND ((main.Disabled = ‘0’)) AND
((main.LookupType = ‘RT::Queue-RT::Ticket’)) AND ((main.id =
ObjectCustomFields_1.CustomField)) GROUP BY main.id ,
ObjectCustomFields_1.sortorder ORDER BY
min(ObjectCustomFields_1.ObjectId) ASC,
min(ObjectCustomFields_1.SortOrder) ASC ) distinctquery, CustomFields main
WHERE
(main.id = distinctquery.id) order by distinctquery.sortorder

But it is a mystery to me how to get RT to run this query. Anyone has any
ideas about this?

RT 3.6.3, PostgreSQL 8.1.8.

Regards
Palle Girgensohn