summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-07-06 13:21:34 +0000
committerGerrit Code Review <review@openstack.org>2016-07-06 13:21:34 +0000
commit24b8812a74979dd6313564d902b28eff562415ba (patch)
treef0de75f990d7f089a4e254ca8374651166b0abd5
parent17ca580dbc47bc23fa951be839bb6aed04dd0698 (diff)
parent16886e55bd8fde77f71d75c3c87c2f71ee6dbd4f (diff)
downloadoslo-db-24b8812a74979dd6313564d902b28eff562415ba.tar.gz
Merge "Catch empty value DBDuplicate errors"
-rw-r--r--oslo_db/sqlalchemy/exc_filters.py4
-rw-r--r--oslo_db/tests/sqlalchemy/test_exc_filters.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py
index 7170219..1aeada7 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 5112104..b353e69 100644
--- a/oslo_db/tests/sqlalchemy/test_exc_filters.py
+++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py
@@ -682,6 +682,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(