checks if the complex conditions are overriden in set_from_related
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artist.pm
index af6257c..48538bc 100644 (file)
@@ -47,15 +47,49 @@ __PACKAGE__->has_many(
 
 
 __PACKAGE__->has_many(
-    cds_80s => 'DBICTest::Schema::CD',
-    sub {
-      my ( $me, $as, $self_rsrc, $rel ) = @_;
-      return {
-        "${as}.artist" => (ref $me ? $me->artistid : { '=' => \"${me}.artistid"}),
-        "${as}.year"   => { '>', "1979",
-                            '<', "1990" }
-      };
-    }
+  cds_80s => 'DBICTest::Schema::CD',
+  sub {
+    my $args = shift;
+
+    return (
+      { "$args->{foreign_alias}.artist" => { '=' => { -ident => "$args->{self_alias}.artistid"} },
+        "$args->{foreign_alias}.year"   => { '>' => 1979, '<' => 1990 },
+      },
+      $args->{self_rowobj} && {
+        "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid,
+        "$args->{foreign_alias}.year"   => { '>' => 1979, '<' => 1990 },
+      }
+    );
+  },
+);
+
+__PACKAGE__->has_many(
+  cds_90s => 'DBICTest::Schema::CD',
+  sub {
+    my $args = shift;
+    return (
+      { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
+        "$args->{foreign_alias}.year"   => { '>' => 1989, '<' => 2000 },
+      }
+    );
+  }
+);
+
+
+__PACKAGE__->has_many(
+  cds_84 => 'DBICTest::Schema::CD',
+  sub {
+    my $args = shift;
+    return (
+      { "$args->{foreign_alias}.artist" => { -ident => "$args->{self_alias}.artistid" },
+        "$args->{foreign_alias}.year"   => 1984,
+      },
+      $args->{self_rowobj} && {
+        "$args->{foreign_alias}.artist" => $args->{self_rowobj}->artistid,
+        "$args->{foreign_alias}.year"   => 1984,
+      }
+    );
+  }
 );