Hi all, I'm in a scenario where I have to deal with a playlist and it's slots (a slot is an entry in the playlist).
I'm trying to detect if changes were made on an slot. If so, I would update my playlist's timestamp: # Query the slot to be updated. c.slot = model.Slot.query.get(id) # Get the slot's playlist object. playlist = c.slot.playlist # Update each columns from the sent params (from a web form) for i in c.slot.c.keys(): setattr(c.slot, i, request.params.get(i) or None) if c.slot in session.dirty: playlist.touch() # update the 'last_update' field (datetime) session.flush() It turns out that even if the values were kept unchanged, the slot get's ditry. Of course, I'd understand that as soon as the setattr() is called against the slot, it automaticly gets dirty regardless of the replaced data. But when .flush() occurs, it won't trigger an UPDATE as flush() detects that the data is actually the same: When slot has modified data: BEGIN UPDATE slots SET duration=%s WHERE slots.id = %s [u'60', 9L] UPDATE playlists SET last_update=%s WHERE playlists.id = %s [datetime.datetime(2007, 9, 20, 18, 33, 22, 57373), 2L] COMMIT When slot was kept unchanged: BEGIN UPDATE playlists SET last_update=%s WHERE playlists.id = %s [datetime.datetime(2007, 9, 20, 18, 34, 14, 737232), 2L] COMMIT Is there another way to know if the slot object is going to be UPDATEd? Regards, -- Alexandre CONRAD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---