diff -r 703a263dd618 -r 8ac9ac8d9143 cubicweb/server/sources/native.py --- a/cubicweb/server/sources/native.py Thu May 16 09:40:28 2019 +0200 +++ b/cubicweb/server/sources/native.py Thu May 16 04:42:59 2019 +0200 @@ -716,14 +716,17 @@ mo = re.search(r'\bcstr[a-f0-9]{32}\b', arg) if mo is not None: # postgresql - raise ViolatedConstraint(cnx, cstrname=mo.group(0)) + raise ViolatedConstraint(cnx, cstrname=mo.group(0), + query=query) if arg.startswith('CHECK constraint failed:'): # sqlite3 (new) - raise ViolatedConstraint(cnx, cstrname=arg.split(':', 1)[1].strip()) + raise ViolatedConstraint(cnx, cstrname=arg.split(':', 1)[1].strip(), + query=query) mo = re.match('^constraint (cstr.*) failed$', arg) if mo is not None: # sqlite3 (old) - raise ViolatedConstraint(cnx, cstrname=mo.group(1)) + raise ViolatedConstraint(cnx, cstrname=mo.group(1), + query=query) raise return cursor