Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin - Inject Android Room SQL language on multiple line queries

How can I get multi-line queries to be injected? It works on Room with Java classes, but does Kotlin support this as well?

E.g. I have 2 queries here, and only the top SQL query (1 line) gets injected.

I tried to follow the steps in this guide but could not find the required settings.

There is an issue at https://youtrack.jetbrains.com/issue/KT-13636 which suggests this is fixed, but I'm not sure how to implement the fix.

like image 234
Fawwaz Yusran Avatar asked Jun 17 '18 00:06

Fawwaz Yusran


1 Answers

You can use a raw string which is more readable anyway:

@Dao
interface ItemDao {
    @Query("""
        SELECT * FROM Item
        WHERE Item.id = :id
        """)
    fun loadItemById(id: Long): LiveData<Item>
}
like image 124
ooi Avatar answered Nov 02 '22 11:11

ooi