Flask-User
Flask-User copied to clipboard
Question why SQLDbAdapter.save_object() does pass?
I have found that when I am trying to confirm email, then UserManager__Views.confirm_email_view calls self.db_manager.save_user_and_user_email(user, user_email) witch in turns calls self.db_adapter.save_object(user) and this does nothing silently. It is very confusing behaviour and it results in the user not having 'email_confirmed_at' updated. And I do not see any sensible way of overwriting the SQLDbAdapter.save_object() that is used. I am probably miss configuring something here.
SQLAlchemy uses DB sessions to commit changes to the DB, while other ORMs use object.save().
DbAdapter needs to support either approaches, so it has a object_save() method and a commit() method.
In the SQLDbAdapter implementation, the db_adapter.object_save() does nothing, and the db_adapter.commit() calls SQLAlchemy's db.session.commit().
Perhaps the code is missing a call to db_adapter.commit()???
Thank you for your prompt answer, Grate Work !!!
Ok I have found it :).
I understand now that SQLAlchemy objects do not have save on them as this is not ActiveRecord.
My problem was caused by the fact that I have had twice call
db = flask_sqlalchemy.SQLAlchemy()
in my code, once in main innit script and once in model definition module. And due to that sqlalchemy.util._collections.ScopedRegistry.__call__
, was geting KeyError and creating new session and this one did not contain the changes so updates were impossible. That was one hard thing to find :/