Hi!

I found a quite strange behavior. Reproduction is simple.

Setup:

selfref=Table("selfref", metadata,
    Column("id",Integer, primary_key=True),
    Column("id_par",Integer, ForeignKey("selfref.id"))
    )

class SelfRef(object):pass

mapper(SelfRef, selfref, properties={
    "children":relation(SelfRef, cascade="all")
  })

Following construction is fine:

sr1 = SelfRef()
sr1.children.append(SelfRef())

but

sr1 = SelfRef().children.append(SelfRef())

will raise

Traceback (most recent call last):
  File "./selfref.py", line 22, in ?
    sr1 = SelfRef().children.append(SelfRef())
  File "/usr/lib/python2.4/site-packages/sqlalchemy/attributes.py", line
386, in append
    self.__setrecord(item)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/attributes.py", line
362, in __setrecord
    self.attr.append_event(event, self.obj, item)
  File "/usr/lib/python2.4/site-packages/sqlalchemy/attributes.py", line
261, in append_event
    obj._state['modified'] = True
AttributeError: 'NoneType' object has no attribute '_state'

and that is a little bit odd because both constructions are logically
identical, right?

Tested SA versions: 0.2.8, 0.3.6

David

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to