[Dbix-class] DBIx-Class-ResultSet-AdvancedWebSearch

Marc Mims marc at questright.com
Thu Sep 25 21:39:29 BST 2008


* Ash Berlin <ash_cpan at firemirror.com> [080925 11:00]:
>
> On 25 Sep 2008, at 17:19, Marc Mims wrote:
>
>> * Marc Mims <marc at questright.com> [080925 08:48]:
>>> All tests pass with the patch applied.
>>
>> I did, indeed, mirsead the code.  Here's a version that returns the
>> correct $full_name and join condition.
>>
>
> Interesting. that would mean that the tests don't cover enough? Fancy  
> patching them a bit to improve coverage/break with the old patch applied 
> too?

Sure.  This patch adds a test for a deep join condition.  It fails with
my old patch, passes with the new one (and the original code).

	-Marc

diff --git a/t/advanced_search.t b/t/advanced_search.t
index baebb39..fc36288 100644
--- a/t/advanced_search.t
+++ b/t/advanced_search.t
@@ -3,7 +3,7 @@
 use lib 't/lib';
 use DBSchema;
 use Test::More;
-plan tests => 4;
+plan tests => 5;
 
 my $schema = DBSchema::get_test_schema();
 my $dvd_rs = $schema->resultset( 'Dvd' );
@@ -17,3 +17,7 @@ is( $new_rs->count, 2, 'Related like searching' );
 $new_rs = $dvd_rs->advanced_search( { tags => [ 'australian', 'dramat' ] } );
 is( $new_rs->count, 1, 'Searching by tags' );
 
+my $user_rs = $schema->resultset('User');
+$new_rs = $user_rs->advanced_search({ 'owned_dvds.dvdtags.tag.name' => 'comedy' });
+is( $new_rs->count, 2, 'Deep join' );
+
diff --git a/t/lib/DBSchema/ResultSet/User.pm b/t/lib/DBSchema/ResultSet/User.pm
new file mode 100644
index 0000000..c3123c0
--- /dev/null
+++ b/t/lib/DBSchema/ResultSet/User.pm
@@ -0,0 +1,8 @@
+use strict;
+use warnings;
+
+package DBSchema::ResultSet::User;
+
+use base 'DBIx::Class::ResultSet::AdvancedWebSearch';
+
+1;



More information about the DBIx-Class mailing list