Hey there,

I just recently discovered some strange thing.  I have the following
code (thanks jek, for cutting it down):

from sqlalchemy import *
from sqlalchemy.orm import *

metadata = MetaData('sqlite:///')

forums_table = Table('forums', metadata,
                      Column('id', Integer, primary_key=True),
                      Column('forum_id', Integer, ForeignKey
('forums.id')),
                      Column('name', String(60)))
metadata.create_all()

class Forum(object):
    def __init__(self, name=None, parent=None):
        self.name = name
        self.parent = parent

mapper(Forum, forums_table, properties={
    '_children': relation(Forum, backref=backref(
        'parent', remote_side=[forums_table.c.id])),
    })

s = create_session(autocommit=False)

for i in xrange(30):
    f1 = Forum('f1')
    f2 = Forum('f2')
    f3 = Forum('f3')
    s.add(f1)
    s.add(f2)
    s.add(f3)
    s.commit()
    assert f1.id < f2.id < f3.id, (f1.id, f2.id, f3.id)


If you remove the _children property, everything just works as
expected, but on the other hand it does not.

It's kinda ugly to swap values in the unittests because of that and
I'm not sure why this happen. Maybe someone else can has a picture of
what's going on.

Thanks!

Regards,
Christopher.

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

Reply via email to