From 1efee1fa66d94e0f78b1af6e520f536dadd8b0a3 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 14 Mar 2019 12:09:29 +0000 Subject: [PATCH] fix constraint name check in service error handler --- app/service/rest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/service/rest.py b/app/service/rest.py index c27876b14..18768f94f 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -118,7 +118,10 @@ def handle_integrity_error(exc): """ Handle integrity errors caused by the unique constraint on ix_organisation_name """ - if 'services_name_key' or 'services_email_from_key' in str(exc): + if any( + 'duplicate key value violates unique constraint "{}"'.format(constraint) in str(exc) + for constraint in {'services_name_key', 'services_email_from_key'} + ): return jsonify( result='error', message={'name': ["Duplicate service name '{}'".format(