server/posts: reduce warnings from sqlalchemy
...regarding empty IN() statements
This commit is contained in:
parent
8be0e731a7
commit
07d0b43d4c
1 changed files with 7 additions and 4 deletions
|
@ -378,10 +378,13 @@ def update_post_relations(post, new_post_ids):
|
||||||
'A relation must be numeric post ID.')
|
'A relation must be numeric post ID.')
|
||||||
old_posts = post.relations
|
old_posts = post.relations
|
||||||
old_post_ids = [int(p.post_id) for p in old_posts]
|
old_post_ids = [int(p.post_id) for p in old_posts]
|
||||||
new_posts = db.session \
|
if new_post_ids:
|
||||||
.query(db.Post) \
|
new_posts = db.session \
|
||||||
.filter(db.Post.post_id.in_(new_post_ids)) \
|
.query(db.Post) \
|
||||||
.all()
|
.filter(db.Post.post_id.in_(new_post_ids)) \
|
||||||
|
.all()
|
||||||
|
else:
|
||||||
|
new_posts = []
|
||||||
if len(new_posts) != len(new_post_ids):
|
if len(new_posts) != len(new_post_ids):
|
||||||
raise InvalidPostRelationError('One of relations does not exist.')
|
raise InvalidPostRelationError('One of relations does not exist.')
|
||||||
if post.post_id in new_post_ids:
|
if post.post_id in new_post_ids:
|
||||||
|
|
Loading…
Reference in a new issue