--- a/cubicweb/devtools/testlib.py Wed May 08 21:37:13 2019 +0200
+++ b/cubicweb/devtools/testlib.py Fri May 10 15:58:01 2019 +0200
@@ -446,10 +446,7 @@
reverse_primary_email=user)
user.cw_clear_relation_cache('in_group', 'subject')
if commit:
- try:
- req.commit() # req is a session
- except AttributeError:
- req.cnx.commit()
+ getattr(req, 'cnx', req).commit()
return user
# other utilities #########################################################
--- a/cubicweb/server/sources/native.py Wed May 08 21:37:13 2019 +0200
+++ b/cubicweb/server/sources/native.py Fri May 10 15:58:01 2019 +0200
@@ -690,7 +690,8 @@
self.debug('transaction has been rolled back')
except Exception:
pass
- if ex.__class__.__name__ == 'IntegrityError':
+ if any(cls.__name__ for cls in ex.__class__.__mro__
+ if cls.__name__ == 'IntegrityError'):
# need string comparison because of various backends
for arg in ex.args:
# postgres, sqlserver