HiveMind icon indicating copy to clipboard operation
HiveMind copied to clipboard

PM FindProjects, orderBy "project" column fails with invalid sql

Open eigood opened this issue 2 years ago • 1 comments

qapps/hm/Project/FindProject, shows all projects for me. Good. I then click "Project Up or Down" error. That gives a parameter orderByField=^workEffortId. The '^' gets converted to UPPER(workEffortId) in the generated sql. However, component/HiveMind/screen/HiveMindRoot/Project/FindProject.xml, the actions/WorkEffortParty has distinct=true, and that conflicts, as I get this postgresql error: Caused by: org.postgresql.util.PSQLException: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

The generated SQL looks like this:

SELECT DISTINCT WEFF.WORK_EFFORT_ID, WEFF.WORK_EFFORT_NAME, WEFF.PRIORITY, WEFF.STATUS_ID, WEFF.ESTIMATED_COMPLETION_DATE, WEFF.ESTIMATED_WORK_TIME, WEFF.ACTUAL_WORK_TIME FROM (public.WORK_EFFORT WEFF LEFT OUTER JOIN public.WORK_EFFORT_PARTY WEP ON WEFF.WORK_EFFORT_ID = WEP.WORK_EFFORT_ID) WHERE (WEFF.WORK_EFFORT_TYPE_ENUM_ID = $1 AND (WEFF.VISIBILITY_ENUM_ID IN ($2, $3) OR (((WEP.FROM_DATE IS NULL OR WEP.FROM_DATE <= $4) AND (WEP.THRU_DATE IS NULL OR WEP.THRU_DATE > $5)) AND WEP.PARTY_ID = $6))) ORDER BY WEFF.WORK_EFFORT_ID ASC NULLS LAST, UPPER(WEFF.WORK_EFFORT_ID) DESC NULLS LAST OFFSET 0 ROWS FETCH FIRST 20 ROWS ONLY

Note the doubled-up order by entries.

This is further conflicted by the show-order-by=case-insenstive in that same xml file.

I'm not sure where to go about fixing this, but it super easy to replicate.

eigood avatar Feb 03 '22 20:02 eigood

Wanting to sort those columns with case insensitivity makes sense, and I don't want to disable that feature. But then I'm not certain why that screen has set distinct=true, so I want to leave that as well. This seems to be a bug in the framework code, and at a guess, if a column has been marked as insenstive-case, the orderBy processing logic should check to see if the field is already in the orderby list, and adjust it in-place to be UPPER().

eigood avatar Feb 04 '22 17:02 eigood