From: Peter Rabbitson Date: Sun, 9 Nov 2008 15:35:30 +0000 (+0000) Subject: Fix detection of multiple rows being returned for single(): calling fetchrow_array... X-Git-Tag: v0.08240~251 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=27252a4a98791c2fcf13693cfbb9f8c44f5e585b;p=dbsrgits%2FDBIx-Class.git Fix detection of multiple rows being returned for single(): calling fetchrow_array in scalar context leads to indefined results (search.cpan.org/~timb/DBI/DBI.pm#fetchrow_array) --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index c6ca8f2..9cb918f 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1406,7 +1406,8 @@ sub select_single { my $self = shift; my ($rv, $sth, @bind) = $self->_select(@_); my @row = $sth->fetchrow_array; - if(@row && $sth->fetchrow_array) { + my @nextrow = $sth->fetchrow_array if @row; + if(@row && @nextrow) { carp "Query returned more than one row. SQL that returns multiple rows is DEPRECATED for ->find and ->single"; } # Need to call finish() to work round broken DBDs