diff --git a/files/routes/comments.py b/files/routes/comments.py index 6b59a5a5c..f28f13a5d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -896,7 +896,7 @@ def save_comment(cid, v): comment=get_comment(cid) - save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() if not save: new_save=SaveRelationship(user_id=v.id, submission_id=comment.id, type=2) @@ -912,7 +912,7 @@ def unsave_comment(cid, v): comment=get_comment(cid) - save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() if save: g.db.delete(save) diff --git a/files/routes/votes.py b/files/routes/votes.py index 3be315e7a..fd11176a2 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -69,7 +69,7 @@ def api_vote_post(post_id, new, v): post = get_post(post_id) # check for existing vote - existing = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).first() + existing = g.db.query(Vote).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id).first() if existing and existing.vote_type == new: return "", 204 @@ -96,8 +96,8 @@ def api_vote_post(post_id, new, v): ) g.db.add(vote) - post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() + post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count() + post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count() g.db.add(post) g.db.commit() return "", 204 @@ -121,7 +121,7 @@ def api_vote_comment(comment_id, new, v): comment = get_comment(comment_id) # check for existing vote - existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).first() + existing = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first() if existing and existing.vote_type == new: return "", 204 @@ -149,8 +149,8 @@ def api_vote_comment(comment_id, new, v): g.db.add(vote) - comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count() - comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count() + comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count() + comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count() g.db.add(comment) g.db.commit() return "", 204 \ No newline at end of file