From: Matt S Trout <mst@shadowcat.co.uk>
Date: Sat, 14 Jan 2006 18:17:23 +0000 (+0000)
Subject: Fixed odd ->search bug caused by S::A brain damage
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad3d2d7c1918602f7bf2bf6fbadd97c890626d78;p=dbsrgits%2FDBIx-Class-Historic.git

Fixed odd ->search bug caused by S::A brain damage
---

diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm
index f0deb88..58d8418 100644
--- a/lib/DBIx/Class.pm
+++ b/lib/DBIx/Class.pm
@@ -131,6 +131,8 @@ Marcus Ramberg
 
 Will Hawes
 
+Todd Lipcon
+
 =head1 LICENSE
 
 You may distribute this code under the same terms as Perl itself.
diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm
index 84169a3..881033e 100644
--- a/lib/DBIx/Class/ResultSet.pm
+++ b/lib/DBIx/Class/ResultSet.pm
@@ -113,7 +113,9 @@ sub search {
   my $where = (@_ ? ((@_ == 1 || ref $_[0] eq "HASH") ? shift : {@_}) : undef());
   if (defined $where) {
     $where = (defined $attrs->{where}
-                ? { '-and' => [ $where, $attrs->{where} ] }
+                ? { '-and' =>
+                    [ map { ref $_ eq 'ARRAY' ? [ -or => $_ ] : $_ }
+                        $where, $attrs->{where} ] }
                 : $where);
     $attrs->{where} = $where;
   }
diff --git a/t/run/06relationship.tl b/t/run/06relationship.tl
index b0f8256..d29998e 100644
--- a/t/run/06relationship.tl
+++ b/t/run/06relationship.tl
@@ -3,7 +3,7 @@ my $schema = shift;
 
 use strict;
 use warnings;  
-plan tests => 17;
+plan tests => 18;
 
 # has_a test
 my $cd = $schema->resultset("CD")->find(4);
@@ -119,10 +119,17 @@ is($undir_maps->count, 1, 'found 1 undirected map for artist 1');
 $undir_maps = $schema->resultset("Artist")->find(2)->artist_undirected_maps;
 is($undir_maps->count, 1, 'found 1 undirected map for artist 2');
 
-my @art = $undir_maps->search_related('mapped_artists')->all;
+my $mapped_rs = $undir_maps->search_related('mapped_artists');
+
+my @art = $mapped_rs->all;
 
 cmp_ok(@art, '==', 2, "Both artist returned from map");
 
+my $searched = $mapped_rs->search({'mapped_artists.artistid' => {'!=', undef}});
+
+cmp_ok($searched->count, '==', 2, "Both artist returned from map after adding another condition");
+
+
 }
 
 1;