-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB: migrate to unique IDs for groups #1333
base: main
Are you sure you want to change the base?
Conversation
@@ -717,7 +797,7 @@ public static int getLoyaltyCardCount(SQLiteDatabase database) { | |||
*/ | |||
public static Cursor getGroupCursor(SQLiteDatabase database) { | |||
return database.rawQuery("select * from " + LoyaltyCardDbGroups.TABLE + | |||
" ORDER BY " + LoyaltyCardDbGroups.ORDER + " ASC," + LoyaltyCardDbGroups.ID + " COLLATE NOCASE ASC", null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Altonss why did you remove COLLATE NOCASE
?
} | ||
|
||
@Override | ||
public boolean equals(@Nullable Object obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we lo longer need .equals()
and .hashCode()
? I think the default implementation is platform-dependent and would usually not consider objects equal if their fields are, only if they are the same object in memory. But I'm not familiar enough with the codebase to be sure that matters.
throw new FormatException("Group has no name: " + record); | ||
} | ||
|
||
DBHelper.insertGroup(database, id, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check for duplicates here, and reuse an existing group with the same name if it already exists.
*/ | ||
private void importCardGroupMappingV3(SQLiteDatabase database, CSVRecord record) throws FormatException { | ||
int cardId = CSVHelpers.extractInt(DBHelper.LoyaltyCardDbIdsGroups.cardID, record); | ||
int groupId = CSVHelpers.extractInt(DBHelper.LoyaltyCardDbIdsGroups.groupID, record); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we reuse an existing group ID in importGroupsV3()
, we need to keep track of it to reuse it here as well.
Edit: should be rebased on #1394.
Based on #1214, closes #1045.
TODO
main
TODO but maybe out of scope for this PR