aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/func/posts.py
diff options
context:
space:
mode:
authorrr-2017-02-02 19:39:57 +0100
committerrr-2017-02-02 19:46:03 +0100
commit07d0b43d4c75738a68651dccf748320a3967f06c (patch)
treed662b78351a87185e18302443c31a72c8b3e1354 /server/szurubooru/func/posts.py
parent8be0e731a7224ec928cc20c70d80eddc04c11eb2 (diff)
server/posts: reduce warnings from sqlalchemy
...regarding empty IN() statements
Diffstat (limited to 'server/szurubooru/func/posts.py')
-rw-r--r--server/szurubooru/func/posts.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py
index 49f384c..de58db0 100644
--- a/server/szurubooru/func/posts.py
+++ b/server/szurubooru/func/posts.py
@@ -378,10 +378,13 @@ def update_post_relations(post, new_post_ids):
'A relation must be numeric post ID.')
old_posts = post.relations
old_post_ids = [int(p.post_id) for p in old_posts]
- new_posts = db.session \
- .query(db.Post) \
- .filter(db.Post.post_id.in_(new_post_ids)) \
- .all()
+ if new_post_ids:
+ new_posts = db.session \
+ .query(db.Post) \
+ .filter(db.Post.post_id.in_(new_post_ids)) \
+ .all()
+ else:
+ new_posts = []
if len(new_posts) != len(new_post_ids):
raise InvalidPostRelationError('One of relations does not exist.')
if post.post_id in new_post_ids:

© 2015 - 2026 Jakob L. Kreuze