jirutka / rsql-parser

Parser for RSQL / FIQL – query language for RESTful APIs
739 stars 156 forks source link

=q= operator and handling nested attributes #27

Closed mlarsson closed 7 years ago

mlarsson commented 7 years ago

When reading the source code I noticed that the QueryOperator enum has a SUB_CONDITION_ANY value attached to "=q=". But I don't see "=q=" mentioned anywhere in the documentation. How does it work and what can we use it for?

Right now I'm trying to transform a RSQL string into a MongoDB query. I need to query for nested attributes, e.g. "documents.status". When doing so I get a node with key "documents.status" but I would expect to get a node with key "documents" containing a node with key "status" so that I in my MongoVisitor could add an elemMatch in between. Are "=q=" somehow related to this and if not how can it be that the default parsing for my query does not yield the expected result ?

Here is a concrete example: documents.status!=CREATED

I get the following mongo expression: { "documents.status" : { "$ne" : "CREATED" } }

But would expect the following: { "documents": { "$elemMatch": { "status": { "$ne" : "CREATED" } } } }

Thank you for your support.

Kind regards Morten

jirutka commented 7 years ago

There’s no SUB_CONDITION_ANY anywhere in the source code of rsql-parser and =q= is not a “standard” RSQL operator, it’s a custom operator.

mlarsson commented 7 years ago

That is a very good answer :smiley: I confused your lib. with another one using you lib. Sorry for taking your time.