Skip to content

Commit

Permalink
api: replace nested_session with commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Nov 3, 2023
1 parent a587e60 commit b9814c7
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions invenio_records/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,25 +439,26 @@ def commit(self, format_checker=None, validator=None, **kwargs):
if self.model is None or self.model.is_deleted:
raise MissingModelError()

with db.session.begin_nested():
if self.send_signals:
before_record_update.send(
current_app._get_current_object(), record=self
)
if self.send_signals:
before_record_update.send(
current_app._get_current_object(), record=self
)

# Run pre commit extensions
for e in self._extensions:
e.pre_commit(self, **kwargs)
# Run pre commit extensions
for e in self._extensions:
e.pre_commit(self, **kwargs)

# Validate also encodes the data
json = self._validate(format_checker=format_checker, validator=validator)
# Validate also encodes the data
json = self._validate(format_checker=format_checker, validator=validator)

# Thus, we pass the encoded JSON directly to the model to avoid
# double encoding.
self.model.json = json
flag_modified(self.model, "json")
# Thus, we pass the encoded JSON directly to the model to avoid
# double encoding.
self.model.json = json
flag_modified(self.model, "json")

db.session.merge(self.model)
# Check this
db.session.merge(self.model)
db.session.commit()

if self.send_signals:
after_record_update.send(current_app._get_current_object(), record=self)
Expand Down

0 comments on commit b9814c7

Please sign in to comment.