[orm-devel] Issue, current CVS

Diedrich Vorberg orm-devel@mailman.tux4web.de
Sat, 23 Nov 2002 10:55:08 +0100


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!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`