[orm-devel] Issue, current CVS

Mike Watkins orm-devel@mailman.tux4web.de
Sat, 23 Nov 2002 02:05:08 -0800


Diedrich,

Good morning ( to you, I guess its morning here but time for sleep in this 
side of the world) - after I sent that note off I checked back through many 
of the previous versions and noted that it was the same. I guess I had not 
done much testing of select(Object...) where the criteria would fail.

I like being able to test simply for some things -

if p:
     do stuff

is much easier to write but perhaps I should be throwing most of these 
object requests into a try: except: block.

Or I can always wrap ds.select in a function if I need to.

PS: For fun earlier this evening I changed the result of _fromTuple to be 
None if an empty result was the answer - was surprised but it 'appears' not 
to have broken anything. I have not done any serious testing on this 
however and am certainly not suggesting that you retrofit it.

Mike

At 10:55 AM 11/23/2002 +0100, you wrote:
>Hi Mike,
>
> >Consider the following:
> >
> >     ds = get_datasource()
> >     p = ds.select(Person, user_name='admin').fetchone()
> >
> >No problem
> >
> >     p = ds.select(Person, user_name='adminnamedoesntexist').fetchone()
> >
> >Rather than returning None, EmptyResultError is being raised. Is this new
> >behaviour? Noted also in 07pre2 as well. I'm assuming the intent is rather
> >to return None to the caller.
>
>er... no. This is what fetchone() always did. I'd hate to change it,
>because it would break so much code :)
>
>Do a cvs update. There is a queryOne method in datasource that will:
>
>   - return None if there is an empty result returned
>   - if there are more than one result row, return the result as is
>   - if there is only one row, but several columns, return the row as
>     a tuple
>   - if the only row has only one column, return the value of the
>     column
>
>This is for stuff like SELECT LAST_INSERTER() or
>SELECT COUNT(id) FROM table etc.
>
>Diedrich
>--
>            _..._                            Diedrich Vorberg
>          .'     '.
>         /  _   _  \                         http://www.tux4web.de
>         | (o)_(o) |                         info@tux4web.de
>          \(     ) /            .---.
>          //'._.'\ \           /     \       Internet Dienstleistungen
>         //   .   \ \          \.@-@./       und 'Consulting'.
>        ||   .     \ \         /`\_/`\
>        |\   :     / |        //  _  \\      Linux Rules!
>        \ `) '   (`  /_      | \     )|_
>      _)``".____,.'"` (_    /`\_`>  <_/ \
>      )     )'--'(     (    \__/'---'\__/
>       '---`      `---`
>
>_______________________________________________
>orm-devel mailing list
>orm-devel@mailman.tux4web.de
>http://mailman.tux4web.de/mailman/listinfo/orm-devel