[sqlalchemy] Re: Two enhancement proposals for orm.Query

2009-06-18 Thread Adrian von Bidder
On Wednesday 17 June 2009 19.08:10 klaus wrote:
 ... whether a query will yield any result ...

 The best approximation
 seems to be
  query.first() is not None
 which can select a lot of columns. I often see
  query.count()  0
 which can become quite expensive on a DBMS like PostgreSQL.

Just a side note that pg tends to compute first() efficiently if (and I 
assume sa does this) the implementation uses LIMIT to tell the db that 
really only the first row is interesting.  I don't know about other 
databases.

cheers
-- vbi


-- 
this email is protected by a digital signature: http://fortytwo.ch/gpg



signature.asc
Description: This is a digitally signed message part.


[sqlalchemy] Re: Two enhancement proposals for orm.Query

2009-06-17 Thread Michael Bayer



On Jun 17, 1:08 pm, klaus klaus.barthelm...@haufe.de wrote:
 not to technicalities in the data model. Would it be difficult to make
 something like
     session.query(B).join(ref, backward=True)
 work?

kw arguments per join condition aren't really an option to join()
since join() is designed to construct multiple joins at once.   What
you're looking for is available right now:

query(B).join(A.bs)

query(B, A).join(A.bs)

theres another use which raises an error:

aalias = aliased(A)
query(B).join((aalias, A.bs))

and looking at it, I think a change I made which also causes the below
to raise an error:

query(B).join((A, A.bs))

is probably fine (added #1445 to address this).  the alias version
is erroneous because A.bs should be aalias.bs.
--~--~-~--~~~---~--~~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---