On May 27, 2014, at 12:39 PM, Jon Nelson <jnel...@jamponi.net> wrote:
> I noticed something kinda weird the other day. > Let's say I have an object 'o' with two fields: "num" (an integer) and > "nums" (an array of integers). > > Using 'inspect' and some trickery: > >>>> d = dict(sa.inspect(o).attrs) >>>> d['num'].history > History(added=(), unchanged=(10), deleted=()) >>>> d['nums'].history > History(added=(), unchanged=[[20,30]], deleted=()) > > Now, if I change o.num to any other value, the history value changes > (as expected): > >>>> o.num = 15 >>>> d['num'].history > History(added=[15], unchanged=(), deleted=[10]) > > But if I change the array *using append/delete/etc*: > >>>> o.nums.append(40) >>>> d['nums'].history > History(added=(), unchanged=[[20,30,40]], deleted=()) > > But if I change o.nums directly: >>>> o.nums = [ 40,50,60 ] >>>> d['nums'].history > History(added=[[40,50,60]], unchanged=(), deleted=[[20,30,40]]) > > and that seems weird. mutations like append/delete aren't detected automatically unless you use the mutable extension: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/mutable.html# there's a note here for HSTORE but it appears to be missing for ARRAY. -- 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.