Extra (passing) test case generated while investigating the cause of RT#91375
Karen Etheridge [Wed, 18 Dec 2013 23:52:30 +0000 (15:52 -0800)]
t/lib/DBICTest/Schema/Artist.pm
t/relationship/custom_with_null_in_cond.t [new file with mode: 0644]

index 34532dc..a99eb7e 100644 (file)
@@ -147,6 +147,21 @@ __PACKAGE__->has_many(
 );
 __PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork');
 
+__PACKAGE__->has_many(
+    cds_without_genre => 'DBICTest::Schema::CD',
+    sub {
+        my $args = shift;
+        return (
+          {
+            "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
+            "$args->{foreign_alias}.genreid" => undef,
+          }, $args->{self_rowobj} && {
+            "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid,
+            "$args->{foreign_alias}.genreid" => undef,
+          }
+        ),
+    },
+);
 
 sub sqlt_deploy_hook {
   my ($self, $sqlt_table) = @_;
diff --git a/t/relationship/custom_with_null_in_cond.t b/t/relationship/custom_with_null_in_cond.t
new file mode 100644 (file)
index 0000000..e7a7acb
--- /dev/null
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use lib 't/lib';
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+my $artist_rs = $schema->resultset('Artist');
+
+for my $rel_rs(
+  $artist_rs->search_related_rs(
+    cds_without_genre => { artist => 1 }, { order_by => 'cdid' }
+  ),
+  $artist_rs->find(1)->search_related_rs(
+    cds_without_genre => {}, { order_by => 'cdid' }
+  ),
+) {
+
+  is_deeply(
+    $rel_rs->all_hri,
+    [
+      {
+        artist => 1,
+        cdid => 2,
+        genreid => undef,
+        single_track => undef,
+        title => "Forkful of bees",
+        year => 2001
+      },
+      {
+        artist => 1,
+        cdid => 3,
+        genreid => undef,
+        single_track => undef,
+        title => "Caterwaulin' Blues",
+        year => 1997
+      },
+    ]
+  );
+}
+
+done_testing;