Michael Bayer wrote: > > On Apr 4, 2008, at 2:43 PM, Rick Morrison wrote: > >> Wouldn't this kind of feature be more natural to include in the >> Query constructor itself, to make Query() somewhat orthogonal with >> select()? >> >> i.e. >> session.query([MappedObject.id, >> MappedObject.name]).filter(...).all() >> >> instead of >> >> session.query(MappedObject).filter(...).values(MappedObject.id, >> MappedObject.name).all() >> For more options, visit this group at >> http://groups.google.com/group/sqlalchemy?hl=en >> -~----------~----~----~----~------~----~------~--~--- >> > > right now, its because something like this: > > sess.query(MappedObject.id, SomeOtherObject.foo, > SomeThirdObject.somethingelse).join('foo') > > is ambiguous. The query's notion of "mapper zero" is a significant > factor in how it works right now. So I like that the Query() has an > explicit "mapper zero", which when mapper-zero-like functions like > join(), with_polymorphic(), eagerload(), deferred(), etc. etc. are > called, theres no guesswork, or rules like "the first column > determines the 'main' table". > > I havent seen anyone propose any other ways around that concept, but > whatever we come up with I would like to keep things as simple as > possible...i think the assumption that Query always has a "root" table > has held up pretty well.
How about keeping it explicit: query(A.id, Node.name) -> ok query(A.id, Node.name).join('foo') -> 'nothing to relate to' error query(A.id, Node.name).mapper_zero(A).join('node') -> hooray --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---