From b0e3162123a2baf1b3dff0abb14fd00ca81c0dd2 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Tue, 7 Nov 2023 14:59:07 -0500 Subject: [PATCH] Change bot to use update query. --- classes/voting_views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/voting_views.py b/classes/voting_views.py index 9c1097f..4e9c0c2 100644 --- a/classes/voting_views.py +++ b/classes/voting_views.py @@ -7,7 +7,7 @@ from typing import List import nextcord from nextcord import SelectOption from nextcord.interactions import Interaction -from sqlalchemy import exc, select +from sqlalchemy import exc, select, update from sqlalchemy.orm import Session from config import DakinyConfig @@ -56,12 +56,12 @@ class VoteSelect(nextcord.ui.StringSelect): except exc.IntegrityError: session.rollback() stmt = ( - select(Votes) + update(Votes) .where(Votes.ElectionCycle == election_name) .where(Votes.VoterId == interaction.user.id) + .values(VotedForId=voted_for) ) - vote = session.scalar(stmt) - vote.VotedForId = voted_for + session.execute(stmt) session.commit() vote_message_str = build_votes_str(self.config)