it runs for me with 0.3.6 and the trunk.

the end of the output is:

2007-04-12 16:57:20,733 INFO sqlalchemy.engine.base.Engine.0x..b0  
SELECT addresses.id_user AS addresses_id_user, addresses.id AS  
addresses_id, addresses.addr AS addresses_addr
FROM addresses, users
WHERE (users.id = ?) AND users.id = addresses.id_user ORDER BY  
addresses.oid
2007-04-12 16:57:20,735 INFO sqlalchemy.engine.base.Engine.0x..b0 [1]
bob's house
bob's flat

send the stacktrace youre getting, thatll tell all.



On Apr 12, 2007, at 4:25 PM, ml wrote:

> See attachment. Tested against 0.3.6.
>
>
>
> Michael Bayer napsal(a):
>>
>> On Apr 12, 2007, at 12:53 PM, ml wrote:
>>
>>> I tried s.query(Address).select_by(user=u) as I found similar in the
>>> documentation
>>> (http://www.sqlalchemy.org/docs/
>>> datamapping.html#datamapping_selectrelations_relselectby)
>>> but SA raises:
>>> AttributeError: 'LazyLoader' object has no attribute 'columns'
>>>
>>
>>
>> works for me, cant reproduce.  please attach a full reproducing test
>> case.
>>
>>>
>>
>
> >
> #!/usr/bin/python2.4
> # -*- coding: utf-8 -*-
>
> from sqlalchemy3 import *
> import datetime, pickle, sys
>
> engine = create_engine("sqlite://", echo=True)
>
> metadata = BoundMetaData(engine)
>
> users_table = Table("users", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("user_name", String(16))
> )
>
> addresses_table = Table("addresses", metadata,
>     Column("id", Integer, primary_key=True),
>     Column("id_user", Integer, ForeignKey("users.id")),
>     Column("addr", String(100))
> )
>
> class User(object):
>     def __init__(self, user_name):
>         self.user_name = user_name
>
> class Address(object):
>     def __init__(self, addr):
>         self.addr = addr
>
> mapper(Address, addresses_table)
> mapper(User, users_table, properties = {
>         "addresses" : relation(Address, cascade="all, delete-orphan",
>                                backref=backref("user")),
>     }
>   )
>
> metadata.create_all(engine)
>
> s = create_session(bind_to=engine)
>
> u1 = User("bob")
> a1 = Address("bob's house")
> a2 = Address("bob's flat")
> u1.addresses.append(a1)
> u1.addresses.append(a2)
> s.save(u1)
>
> u2 = User("alice")
> a3 = Address("alice's house")
> a4 = Address("alice's flat")
> u2.addresses.append(a3)
> u2.addresses.append(a4)
> s.save(u2)
>
> s.flush()
>
> u = s.query(User).get_by_user_name("bob")
> for i in s.query(Address).select_by(user=u):
>     print i.addr
>


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