On 11/03/2015 03:21 PM, c.bu...@posteo.jp wrote:
Is there a way to find out if a persistent sqlalchemy mapped object was
modified?

It means I recieve a object (persistent, with identiy) from the
database. Then the user (maybe!) modify its data in a dialog-window.

   obj = session.query(MyClass).first()
   LetTheUserDoSomethingWithIt(obj)
   if obj.is_modified()

Is there a way to find out if the object in memory/RAM was modified
compared to its instance in the database itself? I don't want to
compare each attribute against the data in the dialog-window.


session.is_modified(obj) will do this for you:


http://docs.sqlalchemy.org/en/rel_1_0/orm/session_api.html?highlight=is_modified#sqlalchemy.orm.session.Session.is_modified

read the docs carefully, this method can be tricky.






--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to