Skip to content

Commit

Permalink
Fixing restore for MySQL 5.x, which will not accept an alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Jun 29, 2023
1 parent 34a41ab commit a5c9dbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/relstorage/adapters/mysql/mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,17 @@ def restore(self, cursor, batcher, oid, tid, data):
Used for copying transactions into this database.
"""
if self.version_detector.requires_values_upsert_alias(cursor):
alias = 'AS NEW'
def VALUES(col):
return 'NEW.' + col
else:
alias = ''
def VALUES(col):
return f'VALUES({col})'

if self.keep_history:
suffix = f"""
AS NEW
{alias}
ON DUPLICATE KEY UPDATE
tid = {VALUES('tid')},
prev_tid = {VALUES('prev_tid')},
Expand All @@ -114,7 +116,7 @@ def VALUES(col):
"""
else:
suffix = f"""
AS NEW
{alias}
ON DUPLICATE KEY UPDATE
tid = {VALUES('tid')},
state_size = {VALUES('state_size')},
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/tests/blob/blob_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def client(client_num):
threads = [threading.Thread(target=client, args=(i,))
for i in range(self.CLIENT_COUNT)]
for thread in threads:
thread.setDaemon(True)
thread.daemon = True
thread.start()

for thread in threads:
Expand Down

0 comments on commit a5c9dbb

Please sign in to comment.