Search code examples
androidandroid-sqliteandroid-roomandroid-jetpack

Calling custom SQLite functions in Room


I include a custom build of sqlite in my app. I have several custom functions in that library, and I would like to call them from @Query in my Room DAOs. However I get an error that Room couldn't find those functions. Is there a way to tell Room that they exist WITHOUT using a @RawQuery?


Solution

  • From Google:

    Room can't verify queries with custom functions, please annotate your method with @SkipQueryVerification.

    Room verifies your Dao queries using sqlite-jdbc which uses a vanilla prebuilt SQLite native library which doesn't have your custom functions and thus causes the verifier to fail. However, with the @SkipQueryVerification you can make Room skip verifying that query allowing you to still use Room but losing the ability to verify the query at runtime.