Skip to content

Error trying to parse with weird named relation (case-sensitivity of keywords): CQLParseException: expected boolean, got '/' #17

@Querela

Description

@Querela

The CQLParser throws an error which could be due to case-sensitivity when handling CQL keywords. I was testing on the example query in the LOC CQL spec (section 12) for the query dc.TitlE Any/rEl.algOriThm=cori fish soRtbY Dc.TitlE.

Both the LOC and OASIS specs mention case-insensitivity:

All parts of CQL are case insensitive apart from user supplied search terms, values for modifiers and prefix map identifiers [...]

To reproduce the issue (at latest commit: 6251e96):

CQLParser parser = new CQLParser();
String cql = "dc.TitlE Any/rEl.algOriThm=cori fish soRtbY Dc.TitlE";
parser.parse(cql);
Exception in thread "main" org.z3950.zing.cql.CQLParseException: expected boolean, got '/'
        at org.z3950.zing.cql.CQLParser.parseQuery(CQLParser.java:189)
        at org.z3950.zing.cql.CQLParser.parseTopLevelPrefixes(CQLParser.java:134)
        at org.z3950.zing.cql.CQLParser.parse(CQLParser.java:117)
// line numbers might not align as I have inserted some debug statements...

While I was testing, I found that the following queries did parse differently (always as a CQLTermNode):

  1. dc.TitlE any fish
  2. dc.TitlE ANY fish
  3. dc.TitlE Any fish
  4. dc.TitlE aNy fish

The query 1. did parse the CQLTermNode into index, CQLRelation ("any") and term ("fish").
The queries 2., 3. and 4. did parse into a CQLTermNode with only the term being filled as "dc.TitlE ANY fish"/... and default index/relation.

  1. dc.TitlE other fish
  2. dc.TitlE Other fish

The queries 5. and 6. should probably also parse into a CQLTermNode with the CQLRelation of "other"/"Other". It currently put the full query into the CQLTermNode.term.

The LOC CQL BNF would allow for relations to be any string (even quoted). The OASIS CQL ABNF is a bit more stricter while allowing any string, it doesn't allow quoting: relation-modifiedrelationrelation-namesimple-namesimple-string (so no special characters).

Is this behavior intended? Can it even be fixed (due to backwards compatibility)? It is probably not according to spec if I understand the BNFs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions