ensure unconstrained relations don't show problems
Robert Sedlacek [Thu, 1 Oct 2015 03:50:23 +0000 (03:50 +0000)]
t/00basic.t
t/lib/My/Schema/Result/Person.pm

index 8b58399..a10ec9d 100644 (file)
@@ -109,6 +109,14 @@ subtest 'has_many' => sub {
             2*3, 'full count';
     };
 
+    subtest 'unconstrained' => sub {
+        is $people
+            ->with_parameterized_join(unconstrained_tasks => {})
+            ->$search_count('unconstrained_tasks.id')
+            ->$fetch_count,
+            3, 'unconstrained count';
+    };
+
     subtest 'errors' => sub {
         like exception {
             $people->with_parameterized_join(urgent_assigned_tasks => {})
index 88c11ca..1206d84 100644 (file)
@@ -50,6 +50,18 @@ __PACKAGE__->parameterized_has_many(
   ]
 );
 
+__PACKAGE__->parameterized_has_many(
+  unconstrained_tasks => 'My::Schema::Result::Task',
+  [ [], sub {
+      my $args = shift;
+      +{
+        "$args->{foreign_alias}.assigned_to_id" =>
+          { -ident => "$args->{self_alias}.id" },
+      }
+    }
+  ]
+);
+
 our %ERROR;
 my $_catch_fail = sub {
   my $key = shift;