pop() fails for collection_class=set

Issue #548 resolved
jek created an issue

the 'pop' wrapper on InstrumentedList is implementing list sementics for pop() even if the underlying collection is a set.

Traceback (most recent call last):
  ...
  File "sqlalchemy/lib/sqlalchemy/orm/attributes.py", line 590, in pop
    item = self.data[i](i)
TypeError: 'set' object is unindexable

To fix, need knowledge of the underlying type (e.g. #213) or add a _data_popper ala _data_appender to differentiate.

To workaround, replace {{{item = myobj.collection.pop()}}} on non-empty sets with something like:

  item = list(myobj.collection)[0](0)
  myobj.collection.remove(item)

Comments (4)

  1. Mike Bayer repo owner

    hey jek -

    why not work on #213 ? you can create a sandbox branch if you like. it also is implicated in some features I want to add regarding value collections (i.e. mapped collections of non-entity values)

  2. Log in to comment