Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBIx-Abstract CPAN distribution.

Report information
The Basics
Id: 1695
Status: resolved
Priority: 0/
Queue: DBIx-Abstract

People
Owner: Nobody in particular
Requestors: barancev [...] kazbek.ispras.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.003
Fixed in: (no value)



Subject: Can't use an undefined value as an ARRAY reference at /usr/lib/perl5/site_perl/5.6.1/DBIx/Abstract.pm line 801
I use PostgreSQL data base with DBI and DBD::Pg driver. If a request returns empty result, the return value of fetchrow_arrayref or fetchrow_hashref is undefined. To avoid problem mentioned in subject one must handle this special case. I'd suggest the following changes: 782c782 < my $result = $db->fetchrow_hashref or return {}; --- Show quoted text
> my $result = $db->fetchrow_hashref;
791c791 < my $result = $db->fetchrow_arrayref or return []; --- Show quoted text
> my $result = $db->fetchrow_arrayref;
800c800 < my $result = $db->fetchrow_arrayref or return (); --- Show quoted text
> my $result = $db->fetchrow_arrayref;
813c813 < my $result = $db->fetchall_arrayref() or return {}; --- Show quoted text
> my $result = $db->fetchall_arrayref();
[guest - Mon Oct 21 04:30:30 2002]: Show quoted text
> I use PostgreSQL data base with DBI and DBD::Pg driver. > > If a request returns empty result, the return value of > fetchrow_arrayref or fetchrow_hashref is undefined. To avoid > problem mentioned in subject one must handle this special case. I'd > suggest the following changes:
This is fixed in the latest versions, though not quite as suggested here. I made select_* routines return undef when no results were returned, so that they behave just like fetchrow_*. This is particularly important when one is returning an empty hash. An empty array is false, but an empty hash is true. So returning an empty hash makes it very difficult for the caller to determine if the request was successful. Anyway, this was fixed in 1.004 (but 1.004 has installer issues so use 1.005 instead).