Skip to content

Commit

Permalink
domains: only flush if data not persisted
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack committed Nov 8, 2024
1 parent 72e7cf1 commit a2e8256
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions invenio_accounts/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from flask import current_app
from flask_security import SQLAlchemyUserDatastore, user_confirmed
from invenio_db import db
from sqlalchemy import inspect
from sqlalchemy.orm import joinedload

from .models import Domain, Role, User
Expand Down Expand Up @@ -75,8 +76,9 @@ def commit(self):

def mark_changed(self, sid, uid=None, rid=None, model=None):
"""Save a user to the changed history."""
# needed so that we have the id from the DB on the model
self.db.session.flush()
# add the ID to the model from the DB if needed
if not inspect(model).persistent:
self.db.session.flush()

if model:
if isinstance(model, User):
Expand Down

0 comments on commit a2e8256

Please sign in to comment.