# HG changeset patch # User Florent Cayré # Date 1484880491 -3600 # Node ID 2deb9f6cbb7b44abdcf700dfdd86ce2842bfbc05 # Parent b75fc687c730673d11b844e62fb96916e4989380 [source,native] Generalize the IntegrityError constraint parsing regex This allows catching constraint-related errors that have been translated by psycopg2, replacing surrounding english quotes by french quotes + space for instance. Closes #17047951. diff -r b75fc687c730 -r 2deb9f6cbb7b cubicweb/server/sources/native.py --- a/cubicweb/server/sources/native.py Wed Jan 18 16:50:48 2017 +0100 +++ b/cubicweb/server/sources/native.py Fri Jan 20 03:48:11 2017 +0100 @@ -716,10 +716,10 @@ rtypes = [c.split('.', 1)[1].strip()[3:] for c in columns] raise UniqueTogetherError(cnx, rtypes=rtypes) - mo = re.search('"cstr[a-f0-9]{32}"', arg) + mo = re.search(r'\bcstr[a-f0-9]{32}\b', arg) if mo is not None: # postgresql - raise ViolatedConstraint(cnx, cstrname=mo.group(0)[1:-1]) + raise ViolatedConstraint(cnx, cstrname=mo.group(0)) if arg.startswith('CHECK constraint failed:'): # sqlite3 (new) raise ViolatedConstraint(cnx, cstrname=arg.split(':', 1)[1].strip())