Jean-Philippe Dutreve wrote: > I was using SA 0.3.9 to insert an item in an ordered list with bisect > method insort (py 2.5): > > mapper(Entry, table_entries) > mapper(Account, table_accounts, properties = dict( > entries = relation(Entry, lazy=True, > backref=backref('account', lazy=False), > collection_class=ordering_list('position'), > order_by=[table_entries.c.position]) > )) > bisect.insort(account.entries, an_entry) > > This is not working anymore with SA 0.4 beta5 : the list owns the item > but not the other way. > assert account.entries[0] is an_entry # TRUE > assert an_entry.account is account # FALSE, currently is None > > Remark: it's working if I copy/paste the bisect method in my module.
This is a Python bug: the C version of insort ignores overridden 'insert' methods on classes that derive from list, bypassing SQLAlchemy's collection hooks. In prior SQLAlchemy versions, collections weren't real lists and insort does handle that case properly. I'd suggest using the pure Python versions of the bisect functions going forward. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---