From 693f38e36c6120b0624ee32903ebd724b9b58eb4 Mon Sep 17 00:00:00 2001 From: James Curtis Date: Wed, 27 Nov 2019 15:31:31 +0000 Subject: [PATCH] Fixes issue of invalid SQL syntax if there is only one id in the tuple Using tuple() as part of the string formatting produces a trailing comma when there is only one id. This changes tuple() to join() to produce valid SQL syntax. --- nh_eobs_mobile/controllers/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nh_eobs_mobile/controllers/main.py b/nh_eobs_mobile/controllers/main.py index b75170d3..b0b08343 100755 --- a/nh_eobs_mobile/controllers/main.py +++ b/nh_eobs_mobile/controllers/main.py @@ -908,7 +908,9 @@ def _remove_duplicates(): SELECT w.name FROM nh_clinical_wardboard AS wb LEFT JOIN nh_clinical_location AS w ON wb.ward_id=w.id - WHERE wb.id IN {}""".format(tuple(wardboard_records.ids)) + WHERE wb.id IN ({})""".format( + ','.join(str(r) for r in wardboard_records.ids) + ) request.env.cr.execute(locations_name_query) ward_names = request.env.cr.fetchall() locations = set(ward_names)