diff options
-rw-r--r-- | oslo_db/sqlalchemy/exc_filters.py | 4 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_exc_filters.py | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index 4ad6cf2..ea7536d 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -91,11 +91,11 @@ def _deadlock_error(operational_error, match, engine_name, is_disconnect): @filters("mysql", sqla_exc.IntegrityError, - r"^.*\b1062\b.*Duplicate entry '(?P<value>.+)'" + r"^.*\b1062\b.*Duplicate entry '(?P<value>.*)'" r" for key '(?P<columns>[^']+)'.*$") # NOTE(jd) For binary types @filters("mysql", sqla_exc.IntegrityError, - r"^.*\b1062\b.*Duplicate entry \\'(?P<value>.+)\\'" + r"^.*\b1062\b.*Duplicate entry \\'(?P<value>.*)\\'" r" for key \\'(?P<columns>.+)\\'.*$") # NOTE(pkholkin): the first regex is suitable only for PostgreSQL 9.x versions # the second regex is suitable for PostgreSQL 8.x versions diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py index 7e6caf4..5ec257e 100644 --- a/oslo_db/tests/sqlalchemy/test_exc_filters.py +++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py @@ -511,6 +511,10 @@ class TestDuplicate(TestsExceptionFilter): "mysql", '(1062, "Duplicate entry ' '\'2-3\' for key \'uniq_tbl0a0b\'")', expected_value='2-3') + self._run_dupe_constraint_test( + "mysql", + '(1062, "Duplicate entry ' + '\'\' for key \'uniq_tbl0a0b\'")', expected_value='') def test_mysql_mysqlconnector(self): self._run_dupe_constraint_test( |