I query my room database using an IN query with a list like this
@Query("SELECT * FROM card WHERE cardId IN (:cardIds)")
LiveData<List<Card>> getCardsByIds(List<Integer> cardIds);
But it's then removing duplicates and is returning them in order of the primary key Id's, this is not what I want. I want it to return like the list I gave it in the order it was given to the database, so for instance given a list of <1,3,2,1,4,5,1,2> I want the same back, but right now I'm getting back <1,2,3,4,5> I've looked at getting the data directly from the cursor which seems ridiculous as android insists you don't do this, and I've tried using raw query which I cant seem to get to play nice with my live data, any ideas out there? seems like it should be super straight forward as sqlite does this out the box, is it that room is applying DISTINCT and ORDER BY primary key when returning the data, and if it is does anyone know of a way to change this?
EDIT this clearly asks more than the original question and it may be an sqlite issue rather than an android room issue meaning the tags are more relevant here