On Thu, 4 Sep 2008 18:54:27 -0400 Michael Bayer <[EMAIL PROTECTED]> wrote:
> > as usual, since this one might turn out to be pretty controversial, > I welcome the list to comment on this one. The order_by().get() > idea does fall in the category of "nonsensical" as opposed to > "ambiguous" , perhaps thats the distinction we'd want to go on. > I was thinking about pointing out that distinction myself. get() basically turns order_by() into a no-op, but it isn't at all *ambiguous*. I'm going to agree with the OP in that throwing the order_by() away in this situation isn't really tantamount to guessing. I'm on the fence about an appropriate behavior. In a statically typed language, it's "nonsensical" to declare unused local variables since the compiler optimizes them away anyhow, but it's not "ambiguous" either. By this logic, perhaps the ORDER BY should be optimized away and a warning should be issued, just as a compiler would issue "warning: local variable 'foo' is unreferenced." On the other hand, a limit() followed by a get() *would* be ambiguous: Some might expect it to throw away the limit and always get the item: q = ses.query(A).order_by([A.rank]).limit(5) top5, item123 = q.all(), q.get(123) while others might expect it to apply the limit and return None if the item was discarded by the limit, even if it actually existed: # Is item 123 in the top 5? ses.query(A).order_by([A.rank]).limit(5).get(123) IMO both of these "abuse the ORM", and encouraging writing a more appropriate query would be a Good Thing. I imagine using the "ambiguous" discriminator instead of "nonsensical" might partition the various other query criteria a bit differently as well, but in my present state of mental capacity, order_by() is the only one I can think of that this applies to :) -Kyle --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---