diff --git a/server/szurubooru/db/comment.py b/server/szurubooru/db/comment.py index a91f1fc..94f0125 100644 --- a/server/szurubooru/db/comment.py +++ b/server/szurubooru/db/comment.py @@ -35,7 +35,8 @@ class Comment(Base): @property def score(self): - return object_session(self) \ + from szurubooru.db import session + return session \ .query(func.sum(CommentScore.score)) \ .filter(CommentScore.comment_id == self.comment_id) \ .one()[0] or 0 diff --git a/server/szurubooru/tests/api/test_comment_rating.py b/server/szurubooru/tests/api/test_comment_rating.py index 6a8360a..ac0aa7f 100644 --- a/server/szurubooru/tests/api/test_comment_rating.py +++ b/server/szurubooru/tests/api/test_comment_rating.py @@ -33,7 +33,6 @@ def test_simple_rating(test_ctx, fake_datetime): test_ctx.context_factory(input={'score': 1}, user=user), comment.comment_id) assert 'text' in result - comment = db.session.query(db.Comment).one() assert db.session.query(db.CommentScore).count() == 1 assert comment is not None assert comment.score == 1