[sqlalchemy] eagerload

2010-02-26 Thread Marcin Krol
Hello everyone, I'm having a silly problem on eagerload, when I do: users = session.query(User).options(eagerload('usercity')).all() or users = session.query(User).options(eagerload(User.usercity)).all() Exception: sqlalchemy.exc.ProgrammingError: (ProgrammingError) invalid reference to

Re: [sqlalchemy] eagerload

2010-02-26 Thread Alexandre Conrad
2010/2/26 Marcin Krol mrk...@gmail.com: mapper(City, city_table, properties={'users':relation(User, order_by='user_.id', backref='city_backref')}) Isn't it order_by='user.id' ? -- Alex twitter.com/alexconrad -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] eagerload

2010-02-26 Thread Marcin Krol
Alexandre Conrad wrote: 2010/2/26 Marcin Krol mrk...@gmail.com: mapper(City, city_table, properties={'users':relation(User, order_by='user_.id', backref='city_backref')}) Isn't it order_by='user.id' ? No. I explicitly named table 'user_' for it not to collide with Postgres function

Re: [sqlalchemy] eagerload

2010-02-26 Thread Marcin Krol
Alexandre Conrad wrote: 2010/2/26 Marcin Krol mrk...@gmail.com: mapper(City, city_table, properties={'users':relation(User, order_by='user_.id', backref='city_backref')}) Fixed, I should have specified order_by in a different manner: mapper(User, user_table,

Re: [sqlalchemy] eagerload

2010-02-26 Thread Michael Bayer
On Feb 26, 2010, at 9:05 AM, Marcin Krol wrote: Hello everyone, I'm having a silly problem on eagerload, when I do: users = session.query(User).options(eagerload('usercity')).all() or users = session.query(User).options(eagerload(User.usercity)).all() do not use a string for your

Re: [sqlalchemy] eagerload

2010-02-26 Thread Michael Bayer
On Feb 26, 2010, at 10:20 AM, Marcin Krol wrote: Alexandre Conrad wrote: 2010/2/26 Marcin Krol mrk...@gmail.com: mapper(City, city_table, properties={'users':relation(User, order_by='user_.id', backref='city_backref')}) Fixed, I should have specified order_by in a different manner:

[sqlalchemy] eagerload -- unknown column None in field list

2010-02-05 Thread diana
I only seem to get this error when I I try to eager load a child collection -- eager loading one child item works fine. I've tried: lazy=False on the relation as well as eagerload on the query: query.options(eagerload('foo')) but each time I get: (OperationalError) (1054, Unknown

Re: [sqlalchemy] eagerload -- unknown column None in field list

2010-02-05 Thread Michael Bayer
diana wrote: I only seem to get this error when I I try to eager load a child collection -- eager loading one child item works fine. I've tried: lazy=False on the relation as well as eagerload on the query: query.options(eagerload('foo')) but each time I get:

[sqlalchemy] eagerload polymorphic object's relations, single table inheritance

2009-08-28 Thread Jae Kwon
I've seen similar discussions here, but it's been a while so perhaps things have changed. class Foo(Base): __tablename__ = 'foo' type = Column(Integer) __mapper_args__ = {'polymorphic_on': type} ... class BarFoo(Foo): __mapper_args__ = {'polymorphic_identity': 1} bar_id =

[sqlalchemy] eagerload first in relation?

2009-03-23 Thread David Gardner
I have a simple many to many relationship between two objects: Task and Note, where notes are ordered by a timestamp column most recent first. About 90% of the time what I really want to do is eagerload only the most recent note, is there a way to do this in the mapper? My mapper for Task

[sqlalchemy] eagerload vs having the object and lazy

2008-10-02 Thread az
hi lets say, A points to B. i do a query against A about which things link to some instance of B. then, 1) if i specify eagerload, i get many times same object-data being piped from the server; ok but i dont want it 2) if i dont specify eagerload (lazy), access to each A fires a

[sqlalchemy] eagerload of one column only?

2008-06-22 Thread az
hi i want to fetch/eagerload just one column off a related object. e.g. if A.b pointing to B and B having x,y,z, i want to get all As and the A.b.x, and nothing else from B. it even doesnot actualy matter if it will be really A.b.x or just some A.new_bx made-up column/attribute. can?

[sqlalchemy] eagerload vs. joins

2008-05-07 Thread David Gardner
I've got a small problem, I want to be able to join two related tables in a query (in my case JobInfo-Chunk-Pass) so that I could use the second table in my order_by(), I would also like them to be eagerloaded. The problem is that in the resulting SQL the tables are joined twice, once for the

[sqlalchemy] eagerload and joined table inheritance

2007-12-30 Thread Matt
Hi all, I'm having an issue where I'm doing a query that I want to be loaded all in one select to the database. I have a table ContentLeaf which inherits from Content, I can get the ContentLeaf fields to eagerload by using select_table in the mapper: myjoin =