On Dec 28, 12:07 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> On Dec 28, 2011, at 11:34 AM, Kent wrote:
>
> > Was it your intention to no longer allow this type of query().get()?
>
> > session.query(cls.orderid).get(orderid)
>
> it was !   yes.
>
>
>
> > I get "InvalidRequestError: get() can only be used against a single mapped 
> > class." but the wording is such that I'm not sure you intended to limit 
> > that use case (there is only a single mapped class in that query).
>
> From the POV of that message there's just a Column, and no mapped class, 
> actually being passed.  I knew this wouldn't necessarily be very clear but 
> there was no better message I could think of.
>
>
>
> > I'll change such queries, just wanted to bring it up to see if you intended 
> > it that way.
>
> > (Admittedly, if I recall correctly, when I first added it, I think I was 
> > slightly surprised it worked as I expected...)
>
> amazingly it took me just one second to find the originating issue, which was 
> that the identity map was still being searched, thereby causing the wrong 
> result:
>
> http://www.sqlalchemy.org/trac/ticket/2144

I suspected that subsequent .get() invocations would return just the
column instead of the object, is that what was happening?

>
> When something is used in a way I didn't anticipate, my first instinct is 
> often to first make that unanticipated case raise an error.   That means it's 
> covered and people won't do it.   Later, if we decide it should do something, 
> that can be re-introduced.   It's always easier to unlock a dead end with a 
> well thought out approach, than to make multiple, small modifications to an 
> existing behavior.

That is the right approach, I'm convinced.  I always feel I'm fighting
an eternal battle at work against the other guys' mindset of "make the
program not crash if something unexpected happens, so at least there
is a chance it will keep running..."  Can't stand it.  Things like
"try: catch Exception: pass".  !  It's far better to blow up before
doing damage, even if that damage is only speculative because it
wasn't used in the designed use case.  Later, when that case comes up
you can analyze it and open the dead end, agreed.

Thanks, I've certainly got no issues with the semantics of get()
meaning "get the instance".

-- 
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.

Reply via email to