Fix PyMySQL reference error detection

When PyMySQL experiences a constraing error a unicode string prefix is
prepended part way through the inner_exception string. As a result, we
raise a DBError when we should be raising a DBReferenceError.

Change-Id: I5de1333d933bd28ca535852f4643df2ebbc7f964
This commit is contained in:
Gregory Haynes 2015-02-12 17:51:39 -08:00
parent 2b9d075076
commit ab20754db7

View File

@ -192,7 +192,7 @@ def _sqlite_dupe_key_error(integrity_error, match, engine_name, is_disconnect):
"is not present in table "
"\"(?P<key_table>[^\"]+)\".")
@filters("mysql", sqla_exc.IntegrityError,
r".* 'Cannot add or update a child row: "
r".* u?'Cannot add or update a child row: "
'a foreign key constraint fails \([`"].+[`"]\.[`"](?P<table>.+)[`"], '
'CONSTRAINT [`"](?P<constraint>.+)[`"] FOREIGN KEY '
'\([`"](?P<key>.+)[`"]\) REFERENCES [`"](?P<key_table>.+)[`"] ')