mrrichardasmith / family_vote

Voting for the Democratic Family
0 stars 0 forks source link

Fix problem with SQLAlchemy query where Month is not being verified #39

Closed mrrichardasmith closed 2 years ago

mrrichardasmith commented 2 years ago

The current query does not recognise that the current month has moved on and there is a difference between the current month of todays date and the month recalled from the database for the row.

active = Account.query.filter(Account.username == current_user.username and Account.month == todayDate.month and Account.year == todayDate.year).one()

When the month moves on the query should nolonger pull back the row from the previous month.

mrrichardasmith commented 2 years ago

The Query syntax does not seem to like it when parameters logic is requested in an order that does not match that order of the database model in models.py I reorganised the request into Month, Year, Username which is the order these parameters appear in the model and this resolved the issue.

active = Account.query.filter(Account.month == todayDate.month and Account.year == todayDate.year and Account.username == current_user.username).first()