Search code examples
androidmigrationactiveandroid

ActiveAndroid migration not an error (code 0), syntax error


Does ActiveAndroid not support the "not in" syntax in migrations? Does ActiveAndroid not support subqueries in migrations?

I've run into exceptions like these when running migrations:

java.lang.RuntimeException: Unable to create application com.example.app.YourApp: android.database.sqlite.SQLiteException: not an error (code 0)

Or

java.lang.RuntimeException: Unable to create application com.example.app.YourApp: android.database.sqlite.SQLiteException: near "in": syntax error (code 1): , while compiling: delete from Collections where _id not in


Solution

  • The answer is that ActiveAndroid doesn't support something else (at least not currently): each migration statement must be ONE line, ending in a semicolon.

    If you separate a sql query into multiple lines, ActiveAndroid will take only the first line, and give you different exceptions (such as the above) depending on where your query got cut off.

    Save yourself some time and kill some readability: ActiveAndroid migrations cannot contain newlines (especially likely to run into this if you were trying to make subqueries readable).