diff --git a/server/szurubooru/db/post.py b/server/szurubooru/db/post.py index 2d9c50d3..9717f2fa 100644 --- a/server/szurubooru/db/post.py +++ b/server/szurubooru/db/post.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Integer, DateTime, String, ForeignKey +from sqlalchemy import Column, Integer, DateTime, String, ForeignKey, table from sqlalchemy.orm import relationship, column_property from sqlalchemy.sql.expression import func, select from szurubooru.db.base import Base @@ -60,7 +60,7 @@ class Post(Base): tag_count = column_property( select([func.count('1')]) .where(PostTag.post_id == post_id) \ - .correlate('Post')) + .correlate(table('Post'))) # TODO: wire these fav_count = Column('auto_fav_count', Integer, nullable=False, default=0) diff --git a/server/szurubooru/db/tag.py b/server/szurubooru/db/tag.py index 21553ebb..287eea64 100644 --- a/server/szurubooru/db/tag.py +++ b/server/szurubooru/db/tag.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, Integer, DateTime, String, ForeignKey +from sqlalchemy import Column, Integer, DateTime, String, ForeignKey, table from sqlalchemy.orm import relationship, column_property from sqlalchemy.sql.expression import func, select from szurubooru.db.base import Base @@ -57,7 +57,7 @@ class Tag(Base): post_count = column_property( select([func.count('Post.post_id')]) \ .where(PostTag.tag_id == tag_id) \ - .correlate('Tag')) + .correlate(table('Tag'))) first_name = column_property( select([TagName.name]) \ diff --git a/server/szurubooru/tests/search/test_tag_search_config.py b/server/szurubooru/tests/search/test_tag_search_config.py index e9fbdacc..1bb2a516 100644 --- a/server/szurubooru/tests/search/test_tag_search_config.py +++ b/server/szurubooru/tests/search/test_tag_search_config.py @@ -43,11 +43,11 @@ def test_filter_by_creation_time( verify_unpaged, session, tag_factory, input, expected_tag_names): tag1 = tag_factory(names=['t1']) tag2 = tag_factory(names=['t2']) - tat3 = tag_factory(names=['t3']) + tag3 = tag_factory(names=['t3']) tag1.creation_time = datetime.datetime(2014, 1, 1) tag2.creation_time = datetime.datetime(2014, 6, 1) - tat3.creation_time = datetime.datetime(2015, 1, 1) - session.add_all([tag1, tag2, tat3]) + tag3.creation_time = datetime.datetime(2015, 1, 1) + session.add_all([tag1, tag2, tag3]) verify_unpaged(input, expected_tag_names) @pytest.mark.parametrize('input,expected_tag_names', [ diff --git a/server/szurubooru/util/tags.py b/server/szurubooru/util/tags.py index 593282b9..7fa5126e 100644 --- a/server/szurubooru/util/tags.py +++ b/server/szurubooru/util/tags.py @@ -1,6 +1,6 @@ import datetime -import os import json +import os import re import sqlalchemy from szurubooru import config, db, errors