JustDelete the message instead of iterating during guild remove

This commit is contained in:
Jeremy Zhang 2018-03-25 05:57:00 +00:00
parent 4859b5a379
commit c35743b498

View File

@ -152,9 +152,7 @@ class DatabaseInterface(object):
with self.get_session() as session:
gui = session.query(Guilds).filter(Guilds.guild_id == int(guild.id)).first()
if gui:
dbmsgs = session.query(Messages).filter(Messages.guild_id == int(guild.id)).all()
for msg in dbmsgs:
session.delete(msg)
dbmsgs = session.query(Messages).filter(Messages.guild_id == int(guild.id)).delete()
session.delete(gui)
session.commit()