[Sqlalchemy-tickets] Issue #3513: Caling setattr on model instance automatically adds it to the dbs
Brought to you by:
zzzeek
|
From: Rob v. d. L. <iss...@bi...> - 2015-08-12 22:14:01
|
New issue 3513: Caling setattr on model instance automatically adds it to the dbsession https://bitbucket.org/zzzeek/sqlalchemy/issues/3513/caling-setattr-on-model-instance Rob van der Linde: Not sure if this is a bug or not, but this has been causing us a lot of hassle. We have a CRUD style rest API and when we update an object (model instance), we call setattr on that model instance to update some fields. What we are noticing is that when calling setattr, SQLAlchemy always seems to be adding the object to the DBSession automatically so that when we check out DBSession.dirty, the object was put into the session simply by calling setattr. We have looked at alternative methods, like directly updating __dict__ but that doesn't always work with m2m fields. Is this a bug? is this expected behaviour? Is there anything else we can do to update an object without automatically getting added to the DBSession. |