When a method declared in a model, is there a lock when the method is called that is only unlocked when the session is committed or the method returns?
For example, I declare an SQLAlchemy model as follow:
class FooModel(Base):
    bar = db.Column(db.Integer, default=0)
    def increase_bar():
        self.bar += 1
        db.session.add(self)
        db.session.commit()
(I'm using Flask-SQLAlchemy)
If there are two requests that call foo.increase_bar() at the same time, would foo.bar increase by two (there is a lock and the method is atomic) or just by one (there is no lock and there is a concurrency problem)?
If it is not atomic, is there a way I can make it be?
