Skip to content

Commit

Permalink
Convert IDs in bulk deletes to strings for DB query.
Browse files Browse the repository at this point in the history
Convert IDs into strings to match the format stored in the database
to prevent us receiving mismatching type errors (big int vs. character
varying).
  • Loading branch information
jb3 committed Mar 26, 2024
1 parent 7344282 commit 83c6505
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion metricity/exts/event_listeners/message_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ async def on_raw_message_delete(self, message: discord.RawMessageDeleteEvent) ->
async def on_raw_bulk_message_delete(self, messages: discord.RawBulkMessageDeleteEvent) -> None:
"""If messages are deleted in bulk and we have a record of them set the is_deleted flag."""
async with async_session() as sess:
await sess.execute(update(Message).where(Message.id.in_(messages.message_ids)).values(is_deleted=True))
await sess.execute(update(Message).where(
Message.id.in_([str(mid) for mid in messages.message_ids]),
).values(is_deleted=True))
await sess.commit()


Expand Down

0 comments on commit 83c6505

Please sign in to comment.