[FOLIO-524] CQL translator: support <> (not equal) operator Created: 28/Mar/17  Updated: 12/Nov/18  Resolved: 25/Apr/17

Status: Closed
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: Bug Priority: P3
Reporter: Jakub Skoczen Assignee: frances.webb@cornell.edu
Resolution: Won't Do Votes: 0
Labels: sprint11, sprint12, sprint13
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Issue links:
Relates
relates to CQLPG-24 CQL translator: support Array=String Closed
relates to FOLIO-530 CQL translator: use IS NOT TRUE inste... Closed
Sprint:

 Description   

The support should include both string fields and fields that are arrays (0 element array should match) and nested object (null object should match)

The cases we want to support:

  • String <> "" True if String element exists AND is not empty
  • Array <> "" True if Array element exists AND has at least one non-empty element
  • Array == "" True if Array element doesn't exist OR has no non-empty elements


 Comments   
Comment by frances.webb@cornell.edu [ 28/Mar/17 ]

I put my understanding of the goal in the issue description.

Comment by frances.webb@cornell.edu [ 28/Mar/17 ]

In the spirit of consistency, it seems like we should also have String == "" match records where the string element doesn't exist or is empty. It looks like we already have String = "" matching records where the string exists and may or may not be empty (as an empty string is a substring of any string).

Comment by Julian Ladisch [ 30/Mar/17 ]

To be consistent using any of the predefined cql relations =, ==, <>, <, >, <=, >= with a string should require that the string element exists. Therefore I suggest:

  • String = "" True if String element exists (any value including empty)
  • String == "" True if String element exists AND is empty
  • String <> "" True if String element exists AND is not empty

This has been implemented since Februar 6. Now there are explicit test cases for them:
https://github.com/folio-org/cql2pgjson-java/blob/c19fb2a/src/test/java/org/z3950/zing/cql/cql2pgjson/CQL2PgJSONTest.java#L342-L356
https://github.com/folio-org/cql2pgjson-java/blob/c19fb2a/src/test/resources/existsEmpty.sql

Comment by Julian Ladisch [ 30/Mar/17 ]

The existing implementation has not yet special support for arrays but treats an array like a string so this is already possible:

  • Array == [] True if element exists AND is an empty array (or is a String containing [])
  • Array <> [] True if element exists AND is a non-empty Array (or is a String different from [])
  • Array <> "" True if element exists (because all Arrays at least contain []).
  • Array == "" This is false in the existing implementation because all Arrays at least contain [].

Matching a single array element is also possible:

  • lang = \"en\" True if element lang exists AND contains string element en
  • cql.allRecords=1 NOT lang = \"en\" True if element lang exists AND does not contain string element en
Comment by Julian Ladisch [ 03/Apr/17 ]

Please check whether the NOT and array capabilities implemented in cql2pgjson >= 1.1.0-SNAPSHOT and raml-module-builder/domain-models-runtime >= 10.0.5-SNAPSHOT and described in the readme https://github.com/folio-org/cql2pgjson-java/ are sufficient and report any missing features.

Comment by frances.webb@cornell.edu [ 04/Apr/17 ]

It looks like the work done by Julian Ladisch on FOLIO-530 Closed is a cleaner solution to the intent of this issue than the one I had been working on and that we had discussed in Slack. Before closing this issue out, I'd like to expand the test cases to make sure we're covered by the current implementation. Since this issue is no longer blocking any current tasks I want to make sure that it's entirely correct for the long term.

Comment by Adam Dickmeiss [ 25/Apr/17 ]

Not doing it here, since FOLIO-530 Closed is OK for now

Generated at Thu Feb 08 23:06:26 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.