unittests fail due to ordering issues with python-2.7

Issue #1888 resolved
Anonymous created an issue

when building SQLAlchemy on current Fedora Linux development branch with python-2.7, I'm getting unittest failures due to some results being returned from the database in a different order than the tests expect. I'm not sure precisely whether it is a change in python or some other component that is causing this but I have a patch to fix it.

Comments (6)

  1. Michael Bayer repo owner

    this looks very nice. It would be preferable if the relationship loads used an "order_by" on the relationship, rather than forcing things with sorted:

    diff -r 42eb68664445c217681479b50fc8b32ff6ca1749 test/orm/test_mapper.py
    --- a/test/orm/test_mapper.py   Mon Aug 23 18:17:31 2010 -0400
    +++ b/test/orm/test_mapper.py   Tue Aug 24 09:17:00 2010 -0400
    @@ -1262,8 +1262,11 @@
         def test_eager_degrade(self):
             """An eager relationship automatically degrades to a lazy relationship if eager columns are not available"""
    +        mapper(Address, addresses)
             mapper(User, users, properties=dict(
    -            addresses = relationship(mapper(Address, addresses), lazy='joined')))
    +            addresses = relationship(Address, order_by=addresses.c.id, 
    +                                            lazy='joined')))
             sess = create_session()
             # first test straight eager load, 1 statement

    there's so many hundreds of tests like these and its already tough to keep them all in the same format (as above, it was using an extremely ancient pattern of embedding mapper() in relationship() - yuck !) so at least sticking to the "order by" pattern doesn't start introducing yet another pattern.

  2. Anonymous

    0.6.5 has only a failing unittests due to ordering, thanks!

    I'll attach a patch for the few remaining failures

  3. Log in to comment