this is not necessarily a bug in Rose::DB::Object::Manager, but it is  
questionable so i will raise the issue anyway. :)

when calling get_foos_count, Rose::DB::Object::Manager->get_objects  
does:

       $count = $sth->fetchrow_array;


this was causing me problems (always getting counts of 1) because my  
DBI abstraction layer re-implements fetchrow_array, only ever  
returning a list.

indeed, it takes careful reading between the lines of the DBI docs to  
discern what exactly should happen when fetchrow_array is called in  
scalar context.

from http://search.cpan.org/~timb/DBI-1.54/DBI.pm

   fetchrow_array

        @ary = $sth->fetchrow_array;
   An alternative to fetchrow_arrayref. Fetches the next row of data  
and returns it as a list containing the field values. Null fields are  
returned as undef values in the list.

   If there are no more rows or if an error occurs, then  
fetchrow_array returns an empty list. You should check $sth->err  
afterwards (or use the RaiseError attribute) to discover if the empty  
list returned was due to an error.

   If called in a scalar context for a statement handle that has more  
than one column, it is undefined whether the driver will return the  
value of the first column or the last. So don't do that. Also, in a  
scalar context, an undef is returned if there are no more rows or if  
an error occurred. That undef can't be distinguished from an undef  
returned because the first field value was NULL. For these reasons  
you should exercise some caution if you use fetchrow_array in a  
scalar context.


the second to last sentence does imply that the first field is  
returned in scalar context (at least when there is only one column),  
so i have changed my re-implementation of fetchrow_array to do so,  
but the last sentence does provide a warning, so perhaps you can be  
convinced to change RDBOM line 1500 to

        ($count) = $sth->fetchrow_array;

regards,
michael.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to