Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix syntax error in run_upgrade for schema 57 (#6728)
Browse files Browse the repository at this point in the history
Fix #6727
Related #6655

Co-authored-by: Erik Johnston <erikj@jki.re>
  • Loading branch information
u1-liquid and erikjohnston committed Jan 17, 2020
1 parent 3b72bb7 commit 722b4f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/6728.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug causing `ValueError: unsupported format character ''' (0x27) at index 312` error when running the schema 57 upgrade script.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run_upgrade(cur, database_engine, config, *args, **kwargs):
INSERT INTO local_current_membership (room_id, user_id, event_id, membership)
SELECT c.room_id, state_key AS user_id, event_id, c.membership
FROM current_state_events AS c
WHERE type = 'm.room.member' AND c.membership IS NOT NULL AND state_key like '%' || ?
WHERE type = 'm.room.member' AND c.membership IS NOT NULL AND state_key LIKE ?
"""
else:
# We can't rely on the membership column, so we need to join against
Expand All @@ -66,9 +66,10 @@ def run_upgrade(cur, database_engine, config, *args, **kwargs):
SELECT c.room_id, state_key AS user_id, event_id, r.membership
FROM current_state_events AS c
INNER JOIN room_memberships AS r USING (event_id)
WHERE type = 'm.room.member' and state_key like '%' || ?
WHERE type = 'm.room.member' AND state_key LIKE ?
"""
cur.execute(sql, (config.server_name,))
sql = database_engine.convert_param_style(sql)
cur.execute(sql, ("%:" + config.server_name,))

cur.execute(
"CREATE UNIQUE INDEX local_current_membership_idx ON local_current_membership(user_id, room_id)"
Expand Down

0 comments on commit 722b4f3

Please sign in to comment.