I was thinking about something like:
session.reload( [tile0, tile1, tile2], 'neighbors' ) for example.
That feature would be great because you don't necessary know what
relation you will need later when you do the first query (eagerload is
not enough)

or in the case:
class Tile(object):
     @property
     def neighbors(self):
         return
object_session(self).query(Tile).filter(Tile.id<self.id).all()
have the possibility to query neighbors for many objects at a time.




On Sep 12, 4:22 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Sep 12, 2008, at 4:08 AM, GustaV wrote:
>
>
>
> > The main reason why I wan't to use relations is eagerloading, because
> > it is the only way, as far as I can see, to retrieve data from DB from
> > several objects in one request.
>
> its not the only way.  You load as many kinds of objects from one
> Query as you want, and you can return them separately or route any
> JOIN of your choosing into the collection.  Its equally possible in
> 0.5 as well as 0.4.   0.5 would be:
>
> TileAlias = aliased(Tile)
> sess.query(Tile).join((TileAlias, Tile.id >
> TileAlias.id)).options(contains_eager(Tile.neighbors, alias=TileAlias))
>
> and you can of course get them separately as:
>
> sess.query(Tile, TileAlias).join((TileAlias, Tile.id > TileAlias.id))
>
> in 0.4, youd replace the query.join() with
> query.select_from(join(tiles, tiles_alias, tiles.c.id >
> tiles_alias.c.id)).
>
> > Maybe today that demand doesn't make any sense, but last time I used
> > DB, it was much more efficient to issue 1 big request rather than 50
> > small ones.
>
> it does make sense, and its a central tenet of SQLAlchemy.  The above
> methods are all in the docs.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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