rsql-parser icon indicating copy to clipboard operation
rsql-parser copied to clipboard

How to query for two values of a nested field?

Open gpr-indevelopment opened this issue 4 years ago • 4 comments

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.

gpr-indevelopment avatar Dec 07 '20 13:12 gpr-indevelopment

I have the same problem bro 😢

BrunoJCosta avatar Aug 19 '21 19:08 BrunoJCosta

This has been answered here. https://github.com/jirutka/rsql-parser/issues/29

qnhant5010 avatar Jan 24 '22 14:01 qnhant5010

After tumbling on this problem, i saw what you had missed was using distinct. Internally, the solution in https://github.com/jirutka/rsql-parser/issues/29 used Join, which resulted in duplicated rows in SQL.

qnhant5010 avatar Oct 26 '22 15:10 qnhant5010

Anyone found a way to solve it?

konopkin11 avatar Jul 02 '23 13:07 konopkin11