DB: migrate to unique IDs for groups#1333
Draft
obfusk wants to merge 3 commits intoCatimaLoyalty:mainfrom
Draft
Conversation
obfusk
commented
Jun 1, 2023
| */ | ||
| 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); |
Contributor
Author
There was a problem hiding this comment.
@Altonss why did you remove COLLATE NOCASE?
obfusk
commented
Jun 1, 2023
| } | ||
|
|
||
| @Override | ||
| public boolean equals(@Nullable Object obj) { |
Contributor
Author
There was a problem hiding this comment.
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.
20 tasks
obfusk
commented
Jun 28, 2023
| throw new FormatException("Group has no name: " + record); | ||
| } | ||
|
|
||
| DBHelper.insertGroup(database, id, name); |
Contributor
Author
There was a problem hiding this comment.
We should check for duplicates here, and reuse an existing group with the same name if it already exists.
obfusk
commented
Jun 28, 2023
| */ | ||
| 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); |
Contributor
Author
There was a problem hiding this comment.
If we reuse an existing group ID in importGroupsV3(), we need to keep track of it to reuse it here as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Edit: should be rebased on #1394.
Based on #1214, closes #1045.
TODO
mainTODO but maybe out of scope for this PR