-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 5.7.2, 5.7.3, 5.7.3-SNAPSHOT
-
Fix Version/s: 5.7.3
-
Component/s: Content Views
-
Tags:
Summary: Fix the EL expression returned when using the NXQL IN operator and the list returned by the EL is empty
schema:field IN ? => The EL is using a NULL field or the ('') expression
More details
I have a multivalued string field, activity:issues
It contains references (uid) to documents (IssueDocument) and is filled using the "multiple document suggestion" widget.
Then in another place (a tab) I need to display the list of issues in a content view. The NXQL filter for this content-view is just:
ecm:uuid IN ?
The parameter is:
#{currentDocument.activity.issues}
This works only if the filed is not empty (not null probably, for example when a new document is created). If it is empty, an error is displayed:
Failed to execute query: org.nuxeo.ecm.core.query.QueryParseException: Syntax error: Invalid token <)> at offset 43 in query: SELECT * FROM Document WHERE (ecm:uuid IN ()) ORDER BY dc:title
=> We can see the expression returned just () instead of ('') with the quotes.
So I added a condition to the parameter:
#{empty currentDocument.activity.issues ? ('') ? currentDocument.activity.issues}
The problem is that it still doesn't work if the list is empty. Like if at runtime, the parenthesis were removed:
Syntax error: Invalid token <> at offset 43 in query: SELECT * FROM Document WHERE (ecm:uuid IN '')
I tried by changing the filter to add the parenthesis:
ecm:uuid IN (?)
But then the error is displayed when there is at least one value, because the expression adds the parenthesis too so we have "((":
Syntax error: Invalid token <(> at offset 43 in query: SELECT * FROM Document WHERE (ecm:uuid IN (('9c1178b3-b6ff-4db9-99d8-688f61195a45'))
The workaround found is about having an activity:issues_empty multivalued string field. For "about to create document" event, this field is filled with an empty string. Then, the ternary operator in the EL returns this field:
#{empty currentDocument.activity.issues ? currentDocument.activity.issues_empty ? currentDocument.activity.issues}