# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1558428691 -7200
# Tue May 21 10:51:31 2019 +0200
# Node ID 8f7ab3004b8f9690bcb520908db0d14ff42f6d61
# Parent a4d465a3e77d07cf6a79c121c10b2d6484cd7468
[database/exception] include the query information in database error for better debuging
This will change an exception from something like :
psycopg2.IntegrityError: null value in column "asource" violates not-null constraint
DETAIL: Failing row contains (341471, CWRType, null, null).
To:
psycopg2.IntegrityError: when doing the query 'INSERT INTO entities ( eid, type ) VALUES ( %(eid)s, %(type)s )' with the args '{'type': u'CWRType', 'eid': 341471}' got the error 'null value in column "asource" violates not-null constraint
DETAIL: Failing row contains (341471, CWRType, null, null).'
Tested with sqlite3 and postgresql.
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1558428691 -7200
# Tue May 21 10:51:31 2019 +0200
# Node ID 8f7ab3004b8f9690bcb520908db0d14ff42f6d61
# Parent a4d465a3e77d07cf6a79c121c10b2d6484cd7468
[database/exception] include the query information in database error for better debuging
This will change an exception from something like :
psycopg2.IntegrityError: null value in column "asource" violates not-null constraint
DETAIL: Failing row contains (341471, CWRType, null, null).
To:
psycopg2.IntegrityError: when doing the query 'INSERT INTO entities ( eid, type ) VALUES ( %(eid)s, %(type)s )' with the args '{'type': u'CWRType', 'eid': 341471}' got the error 'null value in column "asource" violates not-null constraint
DETAIL: Failing row contains (341471, CWRType, null, null).'
Tested with sqlite3 and postgresql.
@@ -749,10 +749,13 @@
1 mo = re.match('^constraint (cstr.*) failed$', arg) 2 if mo is not None: 3 # sqlite3 (old) 4 raise ViolatedConstraint(cnx, cstrname=mo.group(1), 5 query=query) 6 + ex.args = ("when doing the query '%s' with the args '%s' got the error '%s'" % ( 7 + query, args, str(ex).strip() 8 + ),) 9 raise 10 finally: 11 query_debug_informations["time"] = (time.time() - start) * 1000 12 emit_to_debug_channel("sql", query_debug_informations) 13 return cursor