server/db: fix ambiguous names
This commit is contained in:
parent
e42cede27c
commit
e8a9c4ad51
4 changed files with 8 additions and 8 deletions
|
@ -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.orm import relationship, column_property
|
||||||
from sqlalchemy.sql.expression import func, select
|
from sqlalchemy.sql.expression import func, select
|
||||||
from szurubooru.db.base import Base
|
from szurubooru.db.base import Base
|
||||||
|
@ -60,7 +60,7 @@ class Post(Base):
|
||||||
tag_count = column_property(
|
tag_count = column_property(
|
||||||
select([func.count('1')])
|
select([func.count('1')])
|
||||||
.where(PostTag.post_id == post_id) \
|
.where(PostTag.post_id == post_id) \
|
||||||
.correlate('Post'))
|
.correlate(table('Post')))
|
||||||
|
|
||||||
# TODO: wire these
|
# TODO: wire these
|
||||||
fav_count = Column('auto_fav_count', Integer, nullable=False, default=0)
|
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.orm import relationship, column_property
|
||||||
from sqlalchemy.sql.expression import func, select
|
from sqlalchemy.sql.expression import func, select
|
||||||
from szurubooru.db.base import Base
|
from szurubooru.db.base import Base
|
||||||
|
@ -57,7 +57,7 @@ class Tag(Base):
|
||||||
post_count = column_property(
|
post_count = column_property(
|
||||||
select([func.count('Post.post_id')]) \
|
select([func.count('Post.post_id')]) \
|
||||||
.where(PostTag.tag_id == tag_id) \
|
.where(PostTag.tag_id == tag_id) \
|
||||||
.correlate('Tag'))
|
.correlate(table('Tag')))
|
||||||
|
|
||||||
first_name = column_property(
|
first_name = column_property(
|
||||||
select([TagName.name]) \
|
select([TagName.name]) \
|
||||||
|
|
|
@ -43,11 +43,11 @@ def test_filter_by_creation_time(
|
||||||
verify_unpaged, session, tag_factory, input, expected_tag_names):
|
verify_unpaged, session, tag_factory, input, expected_tag_names):
|
||||||
tag1 = tag_factory(names=['t1'])
|
tag1 = tag_factory(names=['t1'])
|
||||||
tag2 = tag_factory(names=['t2'])
|
tag2 = tag_factory(names=['t2'])
|
||||||
tat3 = tag_factory(names=['t3'])
|
tag3 = tag_factory(names=['t3'])
|
||||||
tag1.creation_time = datetime.datetime(2014, 1, 1)
|
tag1.creation_time = datetime.datetime(2014, 1, 1)
|
||||||
tag2.creation_time = datetime.datetime(2014, 6, 1)
|
tag2.creation_time = datetime.datetime(2014, 6, 1)
|
||||||
tat3.creation_time = datetime.datetime(2015, 1, 1)
|
tag3.creation_time = datetime.datetime(2015, 1, 1)
|
||||||
session.add_all([tag1, tag2, tat3])
|
session.add_all([tag1, tag2, tag3])
|
||||||
verify_unpaged(input, expected_tag_names)
|
verify_unpaged(input, expected_tag_names)
|
||||||
|
|
||||||
@pytest.mark.parametrize('input,expected_tag_names', [
|
@pytest.mark.parametrize('input,expected_tag_names', [
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from szurubooru import config, db, errors
|
from szurubooru import config, db, errors
|
||||||
|
|
Loading…
Reference in a new issue