turbomanage / storm-gen

Simple ORM for Android SQLite
Apache License 2.0
83 stars 15 forks source link

UpgradeStragey.BACKUP_RESTORE fails while restoring the backed up data #18

Closed turbomanage closed 10 years ago

turbomanage commented 10 years ago

From https://code.google.com/p/storm-gen/issues/detail?id=41

What steps will reproduce the problem?

  1. Create a database with stORM api and an entity in it. Install this app and generate some data. Make sure that the rowId contains some negative values. In my case, I used hashcode of String object to generate the rowId for the object.
  2. Change the entity schema and database version. Make sure that the upgradestrategy is set to BAKCUP_RESTORE
  3. Upgrade the existing app with this new app. Now the data restore step fails with an exception.

What is the expected output? What do you see instead? Expected: Smoother migration to new database schema and data being restored. Seeing: Exception while importing data back to the db.

What version of the product are you using? On what operating system? 0.9.7

Please provide any additional information below.

The InsertHelper.execute() method was returning some negative rowId (-167847) in my case, which is fine. But there is a check to fail the db restore if this rowId is negative which is wrong. The javadoc for InsertHelper.execute() will return -1 in case of failure. But the code checks for any value < 0 and fails the process.