From 00147210530d4569c05adc45ad71e08b4c292cd5 Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 19 Apr 2017 14:44:54 +0200 Subject: [PATCH] server/tags: fix retrieving many tags --- server/szurubooru/func/tags.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/szurubooru/func/tags.py b/server/szurubooru/func/tags.py index fb04324..8afb26f 100644 --- a/server/szurubooru/func/tags.py +++ b/server/szurubooru/func/tags.py @@ -209,10 +209,13 @@ def get_tags_by_names(names: List[str]) -> List[model.Tag]: names = util.icase_unique(names) if len(names) == 0: return [] - expr = sa.sql.false() - for name in names: - expr = expr | (sa.func.lower(model.TagName.name) == name.lower()) - return db.session.query(model.Tag).join(model.TagName).filter(expr).all() + return (db.session.query(model.Tag) + .join(model.TagName) + .filter( + sa.sql.or_( + sa.func.lower(model.TagName.name) == name.lower() + for name in names)) + .all()) def get_or_create_tags_by_names(