Thanks. That's a bug, and it is fixed in r4bc3ace1f2f0.
You can download r4bc3ace1f2f0 by going to:
http://hg.sqlalchemy.org/sqlalchemy/archive/4bc3ace1f2f0.tar.gz
or the latest default:
http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz
The fix will be in 0.6.5.
A simplified version of your code which illustrates the issue is as follows:
from sqlalchemy.orm import *
from sqlalchemy import *
class Mother(object):
pass
class Son(object):
pass
class YoungSon(Son):
pass
metadata = MetaData()
mothers_table = Table('mothers', metadata,
Column('id',Integer, primary_key=True),
Column('son', Integer, ForeignKey('sons.id')),
)
sons_table = Table('sons', metadata,
Column('id',Integer, primary_key=True),
)
mapper(Mother, mothers_table, properties={
'_son':relation(Son, backref=backref('_mother', uselist=False))
})
son_mapper = mapper(Son, sons_table)
mapper(YoungSon, inherits=Son)
s = Son()
m = Mother()
m._son = s
s2 = YoungSon()
s2._mother = m
On Sep 12, 2010, at 10:45 PM, Ernst Arnold wrote:
> Hi Michael
> I made a simplified but I think for the ORM equivalent example which I attach.
> In ExamplesTest.py I commented:
> # essential: ORM canot cope if this comes after s._mother = m
>
> It seems if that condition is not met then there is indefinite
> recursion. Whether that could/should be avoided by the ORM I do not
> know.
>
> I just noticed a mistake. Need to add to ExamplesOrm.py:
> mapper(OldSon, inherits=son_mapper, polymorphic_identity='oldson')
> This did not change the test results.
>
> Thanks for your time
> Ernst
>
>> Michael Bayer:
>> Its impossible for me to assist you further without the benefit of a
>> complete example of what you're doing, including both tables, both >mappers,
>> an example of their manipulation. If you attach a test case make sure its
>> self contained and does not rely on external >libraries other than
>> SQLAlchemy. There should not be recursion issues in SQLAlchemy but its
>> possible that in some cases they are >unavoidable, if things are configured
>> to point to themselves in some way (though I cannot picture how you'd be
>> doing that without >full details).
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
>
> <Examples.py><ExamplesOrm.py><ExamplesTest.py>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.