From 510a8b58e5c735b27885d2c0347d1b54ab6eb387 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 11 Jul 2022 16:17:43 +0200 Subject: ignore empty IDs when retrieving multiple This is for example useful for the template inputs. They should not be sent due to the "disabled" attribute, but we never know what browsers are doing, therefore we stay defensive. The test case already has to do extra steps to prevent those from being sent. --- fietsboek/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fietsboek/util.py b/fietsboek/util.py index d3a4064..f62a0d5 100644 --- a/fietsboek/util.py +++ b/fietsboek/util.py @@ -231,6 +231,8 @@ def retrieve_multiple(dbsession, model, params, name): """ objects = [] for obj_id in params.getall(name): + if not obj_id: + continue query = select(model).filter_by(id=obj_id) obj = dbsession.execute(query).scalar_one_or_none() if obj is None: -- cgit v1.2.3