Android Room alter View (add colum inside select)

Viewed 54

I didn't find anything inside the docs. What is the propper way to alter a view in room? I tried with the way to create a migration, drop the existing view and create a new one with the sql text, but I still get the room error with the difference between "expected and found scheme" (even the sql-s seems identical, I checked with a comparison tool)

1 Answers

For everyone, obviously room is comparing raw strings not the table/view that is being generated from the provided sql text/entity. The problem in my case was that I had an extra space after a comma inside my altered view sql text, which led to a false result when comparing to the sql text room was generating from my entity (even though the generated views where the same). For me it's a little bit of a surprise that room is using the raw sql strings in order to check for integrity..., but now I know.

Edit:

just one tip to always get the exact same sql string. Change the entity as you wish, and compile the app. Even if it crash, room will generate the right sql text for the change that was made inside the entity. Then just open the generated YOURDATABASE_Impl file and search for the table/view.

Related