Skip to content

Commit

Permalink
Fix issue with sqlalchemy >=2.0
Browse files Browse the repository at this point in the history
SQL query needs to be wrapped in sqlalchemy.text.
Using raw string as been removed.
  • Loading branch information
beenje committed Aug 2, 2023
1 parent d55636d commit 1e54829
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ def upgrade():
# Get all user_id/owner_id from channel scoped API keys
# (user is anonymous - username is null)
res = conn.execute(
"""SELECT api_keys.user_id, api_keys.owner_id FROM api_keys
sa.text(
"""SELECT api_keys.user_id, api_keys.owner_id FROM api_keys
INNER JOIN users ON users.id = api_keys.user_id
WHERE users.username is NULL;
"""
)
)
results = res.fetchall()
# Replace the uploader with the key owner (real user instead of the anonymous one)
Expand All @@ -42,10 +44,12 @@ def downgrade():
# Get all user_id/owner_id from channel scoped API keys
# (user is anonymous - username is null)
res = conn.execute(
"""SELECT api_keys.user_id, api_keys.owner_id FROM api_keys
sa.text(
"""SELECT api_keys.user_id, api_keys.owner_id FROM api_keys
INNER JOIN users ON users.id = api_keys.user_id
WHERE users.username is NULL;
"""
)
)
results = res.fetchall()
# Replace the uploader with the key anonymous user
Expand Down

0 comments on commit 1e54829

Please sign in to comment.