From ab20754db71e55b79b9e71e36ad86d9befc89a92 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 12 Feb 2015 17:51:39 -0800 Subject: [PATCH] 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 --- oslo_db/sqlalchemy/exc_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index 5df1eb74..777fda63 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -192,7 +192,7 @@ def _sqlite_dupe_key_error(integrity_error, match, engine_name, is_disconnect): "is not present in table " "\"(?P[^\"]+)\".") @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.+)[`"], ' 'CONSTRAINT [`"](?P.+)[`"] FOREIGN KEY ' '\([`"](?P.+)[`"]\) REFERENCES [`"](?P.+)[`"] ')