Locations database violates primary key constraint
Closed this issue · 1 comments
i077 commented
When a new Repository
is created, the app force quits with an exception:
#################################################################
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: Location.LocationName (code 1555))
#################################################################
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:952)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.arch.persistence.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.java:50)
at android.arch.persistence.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:80)
at edu.cwru.students.cwrumapper.user.DaoLocations_Impl.insertAll(DaoLocations_Impl.java:45)
at edu.cwru.students.cwrumapper.user.Repository.<init>(Repository.java:25)
at edu.cwru.students.cwrumapper.MainActivity.onCreate(MainActivity.java:88)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
... 10 more
This happens when Locations.populateData()
tries to return a nonempty Location array.