hi,

Just wanted to quickly report this issue, didn't had time to write unit 
test for corning the case:
Was upgrading an 0.4.8 legacy project to 0.8.2

Got an SAWarning: This collection has been invalidated in the following 
case:

Original 0.4.8 code:

            self._serials.append(MetaSerial(value=u'))

And failed to add it to the collection.

The fix needed to get rid of the above warning:

            a_serial = MetaSerial(value=u'')
            self._serials.append(a_serial)





*Tables:*

metaserial_table = Table(
    'metaserial', metadata,
    Column('id', Integer, primary_key=True),
    Column('id_request', Integer, ForeignKey("request.id"), nullable=True, 
index=True),
    Column('id_employee', Integer, ForeignKey("item.id"),
           nullable=False, default=lambda: Connection().employee().id, 
index=True),
    Column('value', UnicodeText(), nullable=True),
    Column('date', LocalDateTime(timezone=True), default=func.now(), 
nullable=False))

request_table = Table(
    'request', metadata,
    Column('id', Integer, primary_key=True),
        ...
)

*Mappers:*


requestMapper = mapper(
    Request,
    request_table,
    # save_on_init=False,
    polymorphic_on=request_table.c.type,
    properties={
        ...

        '_serials': relationship(
            MetaSerial,
            primaryjoin=metaserial_table.c.id_request == 
request_table.c.id, lazy=False),


     ....
}

mapper_cached(
    MetaSerial,
    metaserial_table,
    # save_on_init=False,
    properties={
        'employee': relationship(
            Item, primaryjoin=item_table.c.id == 
metaserial_table.c.id_employee
        ),
        '_value': metaserial_table.c.value
    }
)

sorry in case already a known issue.

best,

marc

-- 
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/groups/opt_out.

Reply via email to