[Bast-commits] r4347 - in DBIx-Class/0.08/trunk: lib/DBIx/Class/Storage t

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Tue May 6 19:47:00 BST 2008


Author: jnapiorkowski
Date: 2008-05-06 19:47:00 +0100 (Tue, 06 May 2008)
New Revision: 4347

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/trunk/t/61findnot.t
   DBIx-Class/0.08/trunk/t/71mysql.t
Log:
changed the warning on DBIC::Storage::DBI->select_single so that it wont call fetch_* on an empty sth, updated tests for the above and added a todo test for the wrong count problem

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2008-05-06 13:59:23 UTC (rev 4346)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2008-05-06 18:47:00 UTC (rev 4347)
@@ -1287,7 +1287,9 @@
   my $self = shift;
   my ($rv, $sth, @bind) = $self->_select(@_);
   my @row = $sth->fetchrow_array;
-  carp "Query returned more than one row" if $sth->fetchrow_array;
+  if(@row && $sth->fetchrow_array) {
+    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
   $sth->finish();
   return @row;

Modified: DBIx-Class/0.08/trunk/t/61findnot.t
===================================================================
--- DBIx-Class/0.08/trunk/t/61findnot.t	2008-05-06 13:59:23 UTC (rev 4346)
+++ DBIx-Class/0.08/trunk/t/61findnot.t	2008-05-06 18:47:00 UTC (rev 4347)
@@ -54,7 +54,8 @@
 $artist_rs = $schema->resultset("Artist");
 warning_is {
   $artist_rs->find({}, { key => 'primary' })
-} "DBIx::Class::ResultSet::find(): Query returned more than one row", "Non-unique find generated a cursor inexhaustion warning";
+} "DBIx::Class::ResultSet::find(): Query returned more than one row.  SQL that returns multiple rows is DEPRECATED for ->find and ->single"
+    =>  "Non-unique find generated a cursor inexhaustion warning";
 
 $artist_rs = $schema->resultset("Artist")->search({}, { prefetch => 'cds' });
 warning_is {

Modified: DBIx-Class/0.08/trunk/t/71mysql.t
===================================================================
--- DBIx-Class/0.08/trunk/t/71mysql.t	2008-05-06 13:59:23 UTC (rev 4346)
+++ DBIx-Class/0.08/trunk/t/71mysql.t	2008-05-06 18:47:00 UTC (rev 4347)
@@ -13,7 +13,7 @@
 plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
   unless ($dsn && $user);
 
-plan tests => 5;
+plan tests => 10;
 
 my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
 
@@ -85,6 +85,34 @@
     is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
 }
 
+## Can we properly deal with the null search problem?
+
+use Data::Dump qw/dump/;
+
+NULLINSEARCH: {
+    
+    ok my $artist1_rs = $schema->resultset('Artist')->search({artistid=>6666})
+    => 'Created an artist resultset of 6666';
+    
+    is $artist1_rs->count, 0
+    => 'Got no returned rows';
+    
+    ok my $artist2_rs = $schema->resultset('Artist')->search({artistid=>undef})
+    => 'Created an artist resultset of undef';
+    
+    TODO: {
+    	$TODO = "need to fix the row count =1 when select * from table where pk IS NULL problem";
+	    is $artist2_rs->count, 0
+	    => 'got no rows';    	
+    }
+
+    my $artist = $artist2_rs->single;
+    
+    is $artist => undef
+    => 'Nothing Found!';
+}
+    
+
 # clean up our mess
 END {
     $dbh->do("DROP TABLE artist") if $dbh;




More information about the Bast-commits mailing list