Giter Club home page Giter Club logo

rsql-parser's Introduction

RSQL / FIQL parser

Build Status Coverage Status Codacy code quality Maven Central

RSQL is a query language for parametrized filtering of entries in RESTful APIs. It’s based on FIQL (Feed Item Query Language) – an URI-friendly syntax for expressing filters across the entries in an Atom Feed. FIQL is great for use in URI; there are no unsafe characters, so URL encoding is not required. On the other side, FIQL’s syntax is not very intuitive and URL encoding isn’t always that big deal, so RSQL also provides a friendlier syntax for logical operators and some of the comparison operators.

For example, you can query your resource like this: /movies?query=name=="Kill Bill";year=gt=2003 or /movies?query=director.lastName==Nolan and year>=2000. See examples below.

This is a complete and thoroughly tested parser for RSQL written in JavaCC and Java. Since RSQL is a superset of the FIQL, it can be used for parsing FIQL as well.

RSQL-parser can be used with:

  • rsql-jpa to convert RSQL into JPA2 CriteriaQuery,

  • rsql-mongodb to convert RSQL into MongoDB query using Spring Data MongoDB,

  • q-builders to build (not only) RSQL query in type-safe manner,

  • your own library…

It’s very easy to write a converter for RSQL using its AST. Take a look at very simple and naive converter to JPA2 in less than 100 lines of code here. You may also read a blog article about RSQL by Eugen Paraschiv.

Grammar and semantic

The following grammar specification is written in EBNF notation (ISO 14977).

RSQL expression is composed of one or more comparisons, related to each other with logical operators:

  • Logical AND : ; or and

  • Logical OR : , or or

By default, the AND operator takes precedence (i.e. it’s evaluated before any OR operators are). However, a parenthesized expression can be used to change the precedence, yielding whatever the contained expression yields.

input          = or, EOF;
or             = and, { "," , and };
and            = constraint, { ";" , constraint };
constraint     = ( group | comparison );
group          = "(", or, ")";

Comparison is composed of a selector, an operator and an argument.

comparison     = selector, comparison-op, arguments;

Selector identifies a field (or attribute, element, …) of the resource representation to filter by. It can be any non empty Unicode string that doesn’t contain reserved characters (see below) or a white space. The specific syntax of the selector is not enforced by this parser.

selector       = unreserved-str;

Comparison operators are in FIQL notation and some of them has an alternative syntax as well:

  • Equal to : ==

  • Not equal to : !=

  • Less than : =lt= or <

  • Less than or equal to : =le= or

  • Greater than operator : =gt= or >

  • Greater than or equal to : =ge= or >=

  • In : =in=

  • Not in : =out=

You can also simply extend this parser with your own operators (see the next section).

comparison-op  = comp-fiql | comp-alt;
comp-fiql      = ( ( "=", { ALPHA } ) | "!" ), "=";
comp-alt       = ( ">" | "<" ), [ "=" ];

Argument can be a single value, or multiple values in parenthesis separated by comma. Value that doesn’t contain any reserved character or a white space can be unquoted, other arguments must be enclosed in single or double quotes.

arguments      = ( "(", value, { "," , value }, ")" ) | value;
value          = unreserved-str | double-quoted | single-quoted;

unreserved-str = unreserved, { unreserved }
single-quoted  = "'", { ( escaped | all-chars - ( "'" | "\" ) ) }, "'";
double-quoted  = '"', { ( escaped | all-chars - ( '"' | "\" ) ) }, '"';

reserved       = '"' | "'" | "(" | ")" | ";" | "," | "=" | "!" | "~" | "<" | ">";
unreserved     = all-chars - reserved - " ";
escaped        = "\", all-chars;
all-chars      = ? all unicode characters ?;

If you need to use both single and double quotes inside a quoted argument, then you must escape one of them using \ (backslash). If you want to use \ literally, then double it as \\. Backslash has a special meaning only inside a quoted argument, not in unquoted argument.

Examples

Examples of RSQL expressions in both FIQL-like and alternative notation:

- name=="Kill Bill";year=gt=2003
- name=="Kill Bill" and year>2003
- genres=in=(sci-fi,action);(director=='Christopher Nolan',actor==*Bale);year=ge=2000
- genres=in=(sci-fi,action) and (director=='Christopher Nolan' or actor==*Bale) and year>=2000
- director.lastName==Nolan;year=ge=2000;year=lt=2010
- director.lastName==Nolan and year>=2000 and year<2010
- genres=in=(sci-fi,action);genres=out=(romance,animated,horror),director==Que*Tarantino
- genres=in=(sci-fi,action) and genres=out=(romance,animated,horror) or director==Que*Tarantino

How to use

Nodes are visitable, so to traverse the parsed AST (and convert it to SQL query maybe), you can implement the provided RSQLVisitor interface or simplified NoArgRSQLVisitorAdapter.

Node rootNode = new RSQLParser().parse("name==RSQL;version=ge=2.0");

rootNode.accept(yourShinyVisitor);

How to add custom operators

Need more operators? The parser can be simply enhanced by custom FIQL-like comparison operators, so you can add your own.

Set<ComparisonOperator> operators = RSQLOperators.defaultOperators();
operators.add(new ComparisonOperator("=all=", true));

Node rootNode = new RSQLParser(operators).parse("genres=all=('thriller','sci-fi')");

Maven

Released versions are available in The Central Repository. Just add this artifact to your project:

<dependency>
    <groupId>cz.jirutka.rsql</groupId>
    <artifactId>rsql-parser</artifactId>
    <version>2.1.0</version>
</dependency>

However if you want to use the last snapshot version, you have to add the JFrog OSS repository:

<repository>
    <id>jfrog-oss-snapshot-local</id>
    <name>JFrog OSS repository for snapshots</name>
    <url>https://oss.jfrog.org/oss-snapshot-local</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

License

This project is licensed under MIT license.

rsql-parser's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsql-parser's Issues

support for NOT operator

As far as I know, AND and OR are supported. Logical NOT operator support will be useful as well.

Is the project actively supported

Looking at the number of commits over the past two years and some unanswered questions, I'm wondering if rsql-parser is no longer actively supported or simply a sign of maturity of the project?

FIQL Compliance: filter by just the selector

Hi, thanks for this cool parser, it's been very easy to use so far. Today I came across something that seems worth bringing up. I haven't read the whole FIQL document yet but noticed that just the selector by itself is valid FIQL:

A FIQL constraint is composed of a selector, which identifies a
portion of an entry's content, and an optional comparison/argument
pair, which refines the constraint. When processed, a constraint
yields a Boolean value.

constraint = selector [ comparison argument ]

It is a way to select data in the resource for which that field is present. However, in the readme for this project we find the following:

Comparison is composed of a selector, an operator and an argument.

comparison = selector, comparison-op, arguments;

Indeed, when I specify only the selector and no operator or arguments I get a RSQLParserException (Encountered "" at line 1, column 2.). This seems incongruent with the following quote on the readme:

Since RSQL is a superset of the FIQL, it can be used for parsing FIQL as well.

Maybe there are other parts of FIQL that are not supported in RSQL, I don't know at the moment. Should that wording be changed, or should support for single selectors be added?

I can see how it could be used as a "is not null" check, though that would still leave the "is null" check unsupported by default.

New supported fork

Hey everyone! I've created a fork which I'm planning to maintain. Please feel free to open issue and PR's.

Case insensitive like

Does RSQL have any special way to support case insensitive like queries? We've been using value=*abc* which works well as long as the backing store isn't collated in a case-sensitive way.

Working combination of packages?

Attempting to use rsql-parser with Mongodb (minimal use of Spring). Have

q-builders-1.6
rsql-parser-2.1.0
spring-data-mongodb-1.10.4.RELEASE

That combination lacks QueryConversionPipeline and my code (below) will not compile.

Using

q-builders-1.6
rest-query-engine-0.7.1
spring-data-mongodb-1.10.4.RELEASE

there is the problem that
com.github.rutledgepaulv.rqe.pipes.QueryConversionPipeline (from restquery-engine-0.7.1)

wants
cz.jirutka.rsql.parser.ast.RSQLVisitor

but that class is in another package:
com.github.rutledgepaulv.qbuilders.visitors (from q-builders-1.6)

I have the impression that there has been some refactoring and the various jars to do not play together.

My goal is to be able to turn arbitrary HTTP queries into MongoDB queries. I would prefer to not use Spring, or to use Spring minimally.

My code looks like

    QueryConversionPipeline pipeline = QueryConversionPipeline.defaultPipeline();
    Condition<GeneralQueryBuilder> condition = pipeline.apply(myQueryString, MyClass.class);
    Criteria crit = condition.query(new MongoVisitor());
    FindIterable<Document> it = myMongo.find((BasicDBObject)crit.getCriteriaObject());

In principal, from what I can tell reading the documentation and looking at the code, this should work, but it won't run due to the above-mentioned packaging issues.

So

  1. How to get the above to work?
  2. Is there a way to accomplish the same ends without using spring-data-mongodb?

Thanks!

Jim

Java 1.6 Compatability

RSQL-Parser is currently not compatible with Java 1.6 but it easily could be. It just uses <> and "|" exception matching which are 1.7 source level constructs. Other than those two things, it's fine for 1.6. I have found this project useful but I'm constrained to 1.6 by customer environment. Would be nice to make these small changes and have it work for 1.6.

Unable to use single quotes in the value

When I am trying to parse Node rootNode = new RSQLParser(operators).parse("FIRSTNAME==Vijay's"); This throws cz.jirutka.rsql.parser.RSQLParserException: cz.jirutka.rsql.parser.TokenMgrError: Lexical error at line 1, column 19. Encountered: after : "'s"
at cz.jirutka.rsql.parser.RSQLParser.parse(RSQLParser.java:122)
at rsql.parserTest.RSqlTest.testsingleQuoteCustomOperator(RSqlTest.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: cz.jirutka.rsql.parser.TokenMgrError: Lexical error at line 1, column 19. Encountered: after : "'s"
at cz.jirutka.rsql.parser.ParserTokenManager.getNextToken(ParserTokenManager.java:460)
at cz.jirutka.rsql.parser.Parser.jj_ntk(Parser.java:320)
at cz.jirutka.rsql.parser.Parser.And(Parser.java:57)
at cz.jirutka.rsql.parser.Parser.Or(Parser.java:30)
at cz.jirutka.rsql.parser.Parser.Input(Parser.java:21)
at cz.jirutka.rsql.parser.RSQLParser.parse(RSQLParser.java:119)
... 24 more
Is there any way to use singlequotes (').

Is RSQLParser.parse() thread-safe?

It would be useful if the documentation says whether parsing is thread-safe.

Based on a quick look at what RSQLParser.parse() does, I think it's thread-safe. Is that correct?

How to add orderBy

Is it possible to add orderBy as an operator or how should it be done.

groovy 2.4.5 is outdated and vulnerabilities are reported with that version

groovy 2.4.5 is outdated and vulnerabilities are reported with 2.4.5 version.

Vulnerabilities reported :
When an application with unsupported Codehaus versions of Groovy from 1.7.0 to 2.4.3, Apache Groovy 2.4.4 to 2.4.7 on classpath uses standard Java serialization mechanisms, e.g. to communicate between servers or to store local data, an attacker could bake a special serialized object that will execute code directly when deserialized. All applications that rely on serialization and do not isolate the code that deserializes objects were subject to this vulnerability

Can we upgrade groovy version to 2.5.8?

=q= operator and handling nested attributes

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

~ reserved word

This is more of a question. I noticed that ~ is reserved but I don't see it in the supported operators. I would like to use ~ for fuzzy searches e.g q=name=~bob

However, this is not allowed since it's a reserved keyword. Can you explain the use for "~"?

Is it possible to use arguments as selectors?

Hi, I'm trying to check if the values of two attributes in the database are identical.
Currently the "arguments" field supports only the values of the entries.

So, Is it possible to use/extend the "arguments" as "selectors"?

For ex: The database entry has the following

	Name : "Item1"
		Attributes:
		ParameterA : "ParamA1"
		ParameterB : "ParamB1"
		
	Name : "Item2"
		Attributes:
			ParameterA : "ParamA2"
			ParameterB : "ParamA2"

Here, the query Attributes.ParameterA=="ParamA1" works fine and fetches the "Item1" as a result.

Now, I would like to query the list of "Items" whose Parameters are identical.

Query will be, Attributes.ParameterA==Attributes.ParameterB should fetch "Item2"

Kindly let me know if its feasible.

Thanks

Closing ByteArrayInputStream in cz.jirutka.rsql.parser.RSQLParser.class

v.2.1.0
I can't find where closes a ByteArrayInputStream, that opens in cz.jirutka.rsql.parser.RSQLParser.class on 116 line. I have checked the stream in generated Parser class, but not found. I'm afraid that it not closes.

/**
     * Parses the RSQL expression and returns AST.
     *
     * @param query The query expression to parse.
     * @return A root of the parsed AST.
     *
     * @throws RSQLParserException If some exception occurred during parsing, i.e. the
     *          {@code query} is syntactically invalid.
     * @throws IllegalArgumentException If the {@code query} is <tt>null</tt>.
     */
    public Node parse(String query) throws RSQLParserException {
        if (query == null) {
            throw new IllegalArgumentException("query must not be null");
        }
 -->    InputStream is = new ByteArrayInputStream(query.getBytes(ENCODING));
        Parser parser = new Parser(is, ENCODING.name(), nodesFactory);

        try {
            return parser.Input();

        } catch (Exception | TokenMgrError ex) {
            throw new RSQLParserException(ex);
        }
    }

Not able to run RSQL with criteria "less than or equal" to date

We're currently use RSQL in our REST API project. However, we get following exception when we execute a query like following:

query=createdInstant<=2016-05-20T21:16:50.265Z (createdInstant is a Instant object)
query=schedule<=31-08-1982 10:20:56 (schedule is a Date object)

Exception:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:242) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:181) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:94) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:119) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.JpaPredicateVisitor.visit(JpaPredicateVisitor.java:83) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.JpaCriteriaQueryVisitor.visit(JpaCriteriaQueryVisitor.java:81) ~[rsql-jpa-2.0.0.jar!/:na]
at com.github.tennaito.rsql.jpa.JpaCriteriaQueryVisitor.visit(JpaCriteriaQueryVisitor.java:47) ~[rsql-jpa-2.0.0.jar!/:na]
at cz.jirutka.rsql.parser.ast.AndNode.accept(AndNode.java:42) ~[rsql-parser-2.0.0.jar!/:2.0.0]

By looking at code (PredicateBuilder.java, line 242), it fails when casting argument to Number. Does this mean we can only apply less then equal to number only? Can you provide a patch where we can use Date, Time....... in comparsion? Thanks

How to use limit and offset

Hi, All,

Thanks for all your contribution to the project, I am using this library for my project, I like it very much, but I have a problem about how to set the limit and offset of all the records I retrieve, I checked the testLimit() in the JUnit testing code, but when I use this url:
/rsql?search=userName==S;limit(0,10);
I got exception:
Request processing failed; nested exception is cz.jirutka.rsql.parser.RSQLParserException: cz.jirutka.rsql.parser.ParseException: Encountered " "(" "( "" at line 1, column 20.

So what is the url format to use limit for pagination?

Thanks
Dave

Spliting in modules

Hi,

At first thanks for your work.
I started to work on hibernate visitor on cxf fiql project, but this project is too messy.
I forked your work for support that hibernate and RSQL Builder using cxf ones.
For that i need to support RSQL parser from RSQL AST and definition

here the result https://github.com/diorcety/rsql

Regards,

How to query for two values of a nested field?

Suppose we have a Book class, that has an Authors field. The Author class has a name field.

public class Book {
    
    private List<Author> authors;
}

public class Author {

    private String name;
}

I want to be able to search for all books that has the authors "Rowling" AND "Tolkien" on the same persisted Book object. How can I achieve that?

I have tried things, with no success, like:

  • "authors.name==Rowling;authors.name==Tolkien" - Finds nothing.
  • "authors.name=in=(Rowling,Tolkien)" - Finds two Book objects even though there is only one persisted with both authors.

Empty Query

Hi Everyone,

This is more of a question than an issue.
Is there a way to send empty query to rsql endpoint in case I want to access all records at an endpoint?

I generally access my endpoint with rsql query as
http://localhost:8080/api/things/rsql?query=name=="john"

Can I use same endpoint (with "rsql" at end) with empty query? One way to do it is reverting to the bare endpoint (http://localhost:8080/api/things) but this needs switching URL to bare one.

I tried query="" but it doesn't work.

How to represent an empty filter in rsql

I am not sure if this is already implemented but I have not found this anywhere in the docs.

I am letting the user enter an rsql query to filter records in a table within a spring webservice. This works perfectly fine when a valid query is provided.

But, how to I represent an empty filter? i.e select * from x without any where clause. Passing an empty or null query string to the rsql parser does not work with error: "Encountered EOF at line 0, column 0".

I am currently forced to use workarounds like primaryKey!=-1 or create a similar condition that does not skip any records to achieve this.

Support for suggest next token

Hi,

I'm currently working to have a user autocompletion feature for a RSQL syntax query.
I've seen that the information about the next possible tokens and the information about the current cursor position of the syntax error is within the ParseException class but is not accessible due the ParseException is not exposing this information.

I guess it would be nice to have a general autocompletion feature in the RSQL parser, wouldn't be? Like I could also get suggestion based on a current cursor position?

The only option I currently see is to use reflection to retrieve the information from the ParseException and based on the currentToken and nextToken information provide suggestions or to implement an own grammar e.g. in ANTLR.

Cheers,
Michael

Nested jpa object search

Hi, great work!
I have only a problem with nested object.
I mix your rsql-parser with specification like explaned by Eugen Paraschiv.
I have 2 entity PERSON and ADDRESS (1,n) .
I want to filter the person who have the address id = 5

When I perform the search action dont work!
http://localhost:9090/api/persons/search?q=addresses.id==5
Error:
Unable to locate Attribute with the the given name [addresses.id]

In my jpa entity Person.addresses exist!
This type of search is supported?
What I wrong?

How to use for Abstract Class ?

Suppose We have 3 classes
public abstract class Shape { {
@id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
}

public class Circle extends Shape {
private double radius;
}

public class Book {
private Shape shape;
}

How can i find Radius using Specification written for BOOK

Is it possible to filter by the json fields?

I would like to achieve something like this:
select * from events where params->>'name' = 'name123';
Params is the column of json type and has in it the field 'name'.
So the goal is to filter by the fields that are present in the json.
Is it possible with the usage of rsql parser?

Need to build my own message from cz.jirutka.rsql.parser.ParseException

My application is taking RSQLParserException and converting it to our application specific application.

Now the message created from ParseException::initialise is not usable by our application and I wanted to create my own message using its 3 properties. Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal

I am able to use expectedTokenSequencesVal and tokenImageVal, but since cz.jirutka.rsql.parser.Token is not the public class I am unable to use currentTokenVal. Is cz.jirutka.rsql.parser.Token Intentionally not a public class. Is there alternative way to overwrite ParseException::initialise or some way I can create my own message.

Is it possible to add a complete example for a custom operator?

For the sake of completeness, would it be possible to give a complete example of a custom operator in the documentation?
I understand that semantics of the operator is not a concern of the parser, so my request should really be directed to rsql-jpa. I just could not find a way to open an issue on their project.

Missing RSQLOperators in 2.0.M1

In jirutka/rsql-parser Readme says:

How to add custom operators:
...
Set operators = RSQLOperators.defaultOperators();
...

But there is no "RSQLOperators" class anywhere.

I could find that class in the "master" branch, modified around august 2014. But in 2.0.M1 tag, there's only an enum class with some operators (it was modified around march 2014).

Do I need to use a snapshot release in order to define custom operators?
Do a snapshot release can be used in production environments?

ability to pass nulls in rsql grammer

Is there a syntax to pass nulls in rsql grammer

I try to pass something like say name==tom;ssn== to find names with no ssn but seems the parser gives an exception when there is no parameter post the == .This I am using to pass null values int eh expression .

Is there any way to do this or will it need to be added as an exception in the parser to handle null queries .

Allowing reserved character in selector ?

Currently reserved character are not allowed in selector. In one of my use case selector contains reserved characters.

  1. Is there any way to handle this.
  2. What was the reason for not allowing reserved character in selector. I think it could have been handled like arguments i.e. if reserved characters in selector then it can be quoted.

Thanks

request to support things like

dear Sir,

we were wondering, what the correct way would be to execute the following query

example:

metaData==(name=='license' and value=='CC BY-SA')

our object looks like this and is stored in Mongo and Elastic Search

http://mona.fiehnlab.ucdavis.edu/rest/spectra/252

and we want to query:

give me all data,. which have the metaData name=license and the metaData value='CC BY-SA'

kind regards,

Gert

p.s. really like the general concept and would love to utilize it in our system

Having problems compiling the project

I cloned the project, but there are multiple issues:

  • what is ParseException
  • what is TokenMgrError

anyway, these can be fixed/ignored.

My bigger problem is the generation of the Parser.java class. Can anyone give me the generated code?

Is there a special way to deal with timestamps?

Hi,

Thanks for developing RSQL. I have a question regarding dates. If I want to query a collection based on a date/time, do I use the ISO 8601 string or do I use the "epoch" notation?
mydate=ge=2015-11-20T18:55:30.888Z
or
mydate=ge=1454694230

I am using the rsql-jpa library if that makes a difference.

Thanks.

RSQLParserException from Parse method

im using cz.jirutka.rsql:rsql-parser:2.1.0 and when i pass the string with apostrophe, it throws me an RSQLParserException. im using the parse method of RSQLParser. Any idea about this issue? Expression string like "'child’s toy'"

Map fields support

Sorry for asking the question in a Github Issue.

If I have a query like "myobject.myfield=XXX", the "myfield" must be a property on the "myobject" type for the query to work.

What if the "myobject" is a Map<String, String>? Then the query fails with a NPE.
Am I missing something, or the RSQL parser cannot traverse the Map fields?
Would you be interested in a PR adding such feature?

Thank you!

Support enumeration fields

I'm using Spring Boot, Spring Data Rest and this library.
I followed this tutorial https://www.baeldung.com/rest-api-search-language-rsql-fiql and everything works fine.

I've a problem when a field is an enumeration. In this query:

http://localhost:8082/api/v1/contacts/search?query=type==CUSTOMER

type field is an enumeration defines as:

```

@NotNull
@Enumerated(EnumType.STRING)
@column(nullable = false, columnDefinition = "VARCHAR(30) DEFAULT 'CUSTOMER'")
private ContactType type = ContactType.CUSTOMER;


how am I supposed to make the filter work?

Thanks

Escaped double quote produces RSQLParserException

The documentation states, that it should be possible to use escaped double quotes in a quoted argument, but if I am using name=="\"" as query string, I am getting a RSQLParserException with the following message:
cz.jirutka.rsql.parser.TokenMgrError: Lexical error at line 1, column 31. Encountered: <EOF> after : ""

Support for 'isnull' operator

Overview

None of the existing operators provide support for testing whether a field is null or conversely is not null.

Technically, such an operator would not require arguments, but the grammar currently requires them:

comparison     = selector, comparator, arguments;
arguments      = ( "(", value, { "," , value }, ")" ) | value;

Here are three suggestions for adding this support:

Option 1

Add new operators:

=isnull=
=notnull=

Change the grammar to allow 0 argument comparisons.

Option 2

Add new operator:

=isnull=

The new operator would take any of the following restricted arguments:

  1. true
  2. false
  3. 0 (0 is the same as false)
  4. 1 (1 is the same as true)

Option 3

Allow '()' as an argument for operator '==' and '!='. The empty list implicitly means null in these contexts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.