Query does not work with ORDER BY with two `in` clause in Room Persistence lib

852 Views Asked by At

I am implementing filter in an app where i need to use in clause in sqlite query to fetch data but following does not work:\

@Query("SELECT * FROM NewsItem WHERE category in (:selectedCategories)  and publisher in (:selectedPublishers)  ORDER BY timestamp DESC LIMIT 20 OFFSET :offset")
    Single<List<NewsItem>> getFilteredAscNewsList(int offset, String[] selectedCategories, String[] selectedPublishers);

Snipped that uses above method:

newsDao.getFilteredAscNewsList(offset, selectedCategories, selectedPublishers).subscribe(subscriber);

But when i remove one of the two in clause or ORDER BY clause like following, it works with out any problem:

When I remove ORDER BY clause like following, query works.

    @Query("SELECT * FROM NewsItem WHERE category in (:selectedCategories)  and publisher in (:selectedPublishers)")
    Single<List<NewsItem>> getFilteredAscNewsList(/*int offset, */String[] selectedCategories, String[] selectedPublishers);

Snipped that uses above method:

newsDao.getFilteredAscNewsList(/*offset, */selectedCategories, selectedPublishers).subscribe(subscriber); 

When i remove one of two in clause but keep ORDER BY clause, it still works.

    @Query("SELECT * FROM NewsItem WHERE category in (:selectedCategories)  ORDER BY timestamp DESC LIMIT 20 OFFSET :offset")
    Single<List<NewsItem>> getFilteredAscNewsList(int offset, String[] selectedCategories/*, String[] selectedPublishers*/);

Snipped that uses above method:

newsDao.getFilteredAscNewsList(offset, selectedCategories/*, selectedPublishers*/).subscribe(subscriber);

Am i missing something here or there is a bug in Room lib.

I have checked it with version 1.0.0-alpha9 and 1.0.0-alpha9-1, both don't work.

does Anybody have any idea?

0

There are 0 best solutions below