CMDBuild Forum

Asynchronous task failed on SQL query

Hi, CmdBuild folks !
 
I did a fresh brand install of cmdbuild 2.4 on Windows x64/Tomcat 7/postgres 9.5
Set an "after update" synchronous task on a trivial table with no specific attributes.
When I try to update a card, an SQL error occured and task aborts. The error raised is ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions. The sql query from cmdbuild.log looks like:
 
<code>
SELECT DISTINCT ON ("_firstclass_Id")
firstclass."Code" AS "firstclass#Code", firstclass."Description" AS "firstclass#Description", firstclass."Notes" AS "firstclass#Notes", firstclass.anelement AS "firstclass#anelement", firstclass."IdClass"::oid AS "_firstclass_IdClass", firstclass."Id" AS "_firstclass_Id", firstclass."User" AS "_firstclass_User", firstclass."BeginDate" AS "_firstclass_BeginDate"
FROM firstclass AS firstclass
WHERE ( NOT ( firstclass."Description" IS NULL  ) AND   firstclass."Id" = ? ) AND firstclass."Status" = ?
ORDER BY "firstclass#Description" ASC, "_firstclass_Id"
</code>
 
I ran this query on pgadmin, replacing ? by an item id and it returns the same error.
To correct the error (on sql console) I've just reverse the order by clause and put first the field of the select on order by as the pgsql doc said.
To be short :
<code>
SELECT DISTINCT ON ("_firstclass_Id")
...
ORDER BY  "_firstclass_Id", "firstclass#Description" ASC
</code>
Could it be a bug ?
Regards,
Olivier

Thank you for your report.
It is a known bug and has already been fixed in version 2.4.1 which will be released at the end of this month.
CMDBuild Team