summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-07-16 15:41:05 +0100
committerStephen Finucane <stephenfin@redhat.com>2021-08-10 17:43:22 +0100
commitcd5f697a173a64df0cdb1a90ab871b81f56469d4 (patch)
tree246d38c5173ff0a55e58135d13addb79b2c0791c /oslo_db/sqlalchemy
parentb3a56b35640b0cfceeeb97c885318a3aae7f7b22 (diff)
downloadoslo-db-cd5f697a173a64df0cdb1a90ab871b81f56469d4.tar.gz
Remove use of Session.begin.subtransactions flag
Resolve the following RemovedIn20Warning warning: The Session.begin.subtransactions flag is deprecated and will be removed in SQLAlchemy version 2.0. See the documentation at session_subtransactions for background on a compatible alternative pattern. Change-Id: Ib2537bae77861ee60d17a48a72c57b88e043553e Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'oslo_db/sqlalchemy')
-rw-r--r--oslo_db/sqlalchemy/models.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/oslo_db/sqlalchemy/models.py b/oslo_db/sqlalchemy/models.py
index 2bad0f5..72ac7cb 100644
--- a/oslo_db/sqlalchemy/models.py
+++ b/oslo_db/sqlalchemy/models.py
@@ -34,18 +34,8 @@ class ModelBase(object):
def save(self, session):
"""Save this object."""
-
- # NOTE(boris-42): This part of code should be look like:
- # session.add(self)
- # session.flush()
- # But there is a bug in sqlalchemy and eventlet that
- # raises NoneType exception if there is no running
- # transaction and rollback is called. As long as
- # sqlalchemy has this bug we have to create transaction
- # explicitly.
- with session.begin(subtransactions=True):
- session.add(self)
- session.flush()
+ session.add(self)
+ session.flush()
def __setitem__(self, key, value):
setattr(self, key, value)