I Have room database with Object coin.
I want to make a dynamic query with parameter.
When i use the parameter for a value, it works great, like this:
@Query("select * from coin ORDER BY percent_change_24h asc limit :numberOfCoins")
fun getAllTop(numberOfCoins: Int): Flowable<List<CoinDB>>
But when i want to use a parameter for the WHERE clause, that does not work. here is my query:
@Query("select * from coin ORDER BY :order asc limit :numberOfCoins")
fun getAllTop(order: String, numberOfCoins: Int): Flowable<List<CoinDB>>
And I call it like that:
AppDatabase.getInstance(this).coinDao().getAllTop("percent_change_24h",5)
Calling the same query with implicit WHERE clause work fine (like this:)
@Query("select * from coin ORDER BY percent_change_24h asc limit :numberOfCoins")
fun getAllTop(order: String, numberOfCoins: Int): Flowable<List<CoinDB>>