On Wed, Nov 5, 2008 at 6:10 PM, Sok Ann Yap <[EMAIL PROTECTED]> wrote: > On Wed, Nov 5, 2008 at 5:47 PM, Yap Sok Ann <[EMAIL PROTECTED]> wrote: >> I use a MapperExtension to automatically put the current timestamp >> into a updated_at column for all entities. This works fine except when >> related entities get involved. Let's say I have a Many-To-One relation >> between employees and departments. If I switch the department for an >> employee, even though nothing has really changed for the department >> instance, both employee and department instances will get a new >> timestamp. I would like to know what is the best way to just update >> the employee and skip the department. >> > > One workaround I found is to have a Session with autoflush=False and > autocommit=True, then do Session.flush([employee]). However, that > would require changes to multiple source files. Is there a more > elegant solution? >
Ah, my question has been answered at: http://groups.google.com/group/sqlalchemy/browse_thread/thread/1aa5fd0a72901d2b The solution is to use Session.is_modified(instance, include_collections=False) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
