Can I not have non-abstract methods in my DAO inte...
# room
k
Can I not have non-abstract methods in my DAO interface? I have a DAO function that takes an object, but since you can’t destructure the object directly, I manually unwrap it and call a private method:
Copy code
data class Foo(val x: Int, val y: String)

@Dao interface MyDao {
  @Query("...")
  private suspend fun _getData(x: Int, y: String): Int
  suspend fun getData(foo: Foo) = _getData(foo.x, foo.y)
}
But I get an error when trying to build my project:
Copy code
error: MyDao_Impl is not abstract and does not override abstract method getData(......
How do I resolve this without forcing a non-DAO function to do the unwrapping?
OK, looks like the answer is the pull that non-abstract method out and make it an extension function:
Copy code
@Dao interface MyDao {
  @Query("..")
  suspend fun getData(x: Int, y: String): Int
}

suspend fun MyDao.getData(foo: Foo) = 
getData(foo.x, foo.y)
m
that looks like https://issuetracker.google.com/issues/146825845, which should be fixed in a future edition of Room
👍 1