[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.
--- 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())