server/db: fix ambiguous names
This commit is contained in:
parent
e42cede27c
commit
e8a9c4ad51
|
@ -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)
|
||||
|
|
|
@ -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]) \
|
||||
|
|
|
@ -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', [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import datetime
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sqlalchemy
|
||||
from szurubooru import config, db, errors
|
||||
|
|
Loading…
Reference in New Issue