Closed lydavid closed 4 months ago
Tested with Charles by rewriting with an additional release group, then refreshing. I could not reproduce it. There may have been a bad migration at some point.
I was able to repro on debug app.
Let's make sure to clear total remote count, and refetch it when refreshing.
release-group inside artist screen causing crash:
error: Key "e289b05a-9094-4a17-956f-04bffbc09427" was already used.
select *
from release_group
where id = "e289b05a-9094-4a17-956f-04bffbc09427";
only gives me one result cause it's a primary key
Run getNumberOfReleaseGroupsByArtist
from AS's gutter gives me 64 for artist 9df7ddfb-75fe-4470-9269-5810d9263b09
whereas getBrowseEntityCount
gives 62 for both local and remote count.
Run getReleaseGroupsByArtist
to get the 64 release groups.
Modify with and rg.id = "e289b05a-9094-4a17-956f-04bffbc09427"
to find the problem rg.
They look the same.
Getting rid of LEFT JOIN mbid_image mi ON mi.mbid = rg.id
still gives 2 result.
Querying for the artist or rg from artist_release_group
gives just 1 result.
Problem is:
INNER JOIN artist_credit_entity acr ON acr.entity_id = rg.id
INNER JOIN artist_credit ac ON ac.id = acr.artist_credit_id
removing this will give just 1 result
Selecting acr.*
shows the problem:
This artist has artist_credit_id 10 and 15 (ids chosen by autoincrement).
The simplest fix is to select DISTINCT
.
But I need to prevent duplicates showing up in artist_credit
.
Looking into artist_credit
, I think I found the actual issue. It is because this artist is entered into this table as both HOYO-MiX
and HOYO‐MiX
, where the only difference is in the dash.
The first one is: https://apps.timwhitlock.info/unicode/inspect?s=-
The second one is: https://apps.timwhitlock.info/unicode/inspect?s=%E2%80%90
artist_credit
already checks to ensure we do not insert duplicate names, but cannot possibly check this different unique of unicode characters.
So, in the end, I will just select DISTINCT
and not deal with this unique scenario.
SELECT DISTINCT doesn't work when I need it to be distinct on just one column (rg.id): https://stackoverflow.com/a/5585483
This issue actually came up because of an artist credit name change for a release group upstream after refreshing. Any changes in Unicode counts as a new artist according to our app. I thought about deleting the artist credits as well, but decided against it because other entities may still use the artist credit name. We just need to accept that there may exist some erroneous artist credit names in the app.
Or it might be because a release group was removed. Need to find a way to test for each of these scenarios