Skip to content

Commit

Permalink
Do case-insensitive checking
Browse files Browse the repository at this point in the history
  • Loading branch information
amCap1712 committed Sep 10, 2024
1 parent e552d14 commit 65fc502
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions metabrainz/supporter/copy_mb_row_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def copy_row_ids_for_table(table_name, fetch_query, update_query):
WHERE EXISTS(
SELECT 1
FROM (VALUES %s) AS t(username)
WHERE t.username = e.name
WHERE lower(t.username) = lower(e.name)
)
""", editor_ids, fetch=True)
editors = [(r[0], r[1]) for r in results]
Expand All @@ -41,20 +41,20 @@ def copy_row_ids_for_table(table_name, fetch_query, update_query):


def copy_row_ids():
supporter_fetch_query = "SELECT musicbrainz_id FROM supporter"
supporter_fetch_query = "SELECT musicbrainz_id FROM supporter WHERE musicbrainz_row_id IS NULL"
supporter_update_query = """
UPDATE supporter s
SET musicbrainz_row_id = t.musicbrainz_row_id
FROM (VALUES %s) AS t(musicbrainz_row_id, musicbrainz_id)
WHERE s.musicbrainz_id = t.musicbrainz_id
WHERE lower(s.musicbrainz_id) = lower(t.musicbrainz_id)
"""

payment_fetch_query = "SELECT DISTINCT editor_name FROM payment WHERE editor_name IS NOT NULL"
payment_fetch_query = "SELECT DISTINCT editor_name FROM payment WHERE editor_name IS NOT NULL AND editor_id IS NULL"
payment_update_query = """
UPDATE payment p
SET editor_id = t.musicbrainz_row_id
FROM (VALUES %s) AS t(musicbrainz_row_id, musicbrainz_id)
WHERE p.editor_name = t.musicbrainz_id
WHERE lower(p.editor_name) = lower(t.musicbrainz_id)
"""

copy_row_ids_for_table("supporter", supporter_fetch_query, supporter_update_query)
Expand Down

0 comments on commit 65fc502

Please sign in to comment.