Merge branch 'current/for_cpan_index' into current/dq
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artist.pm
index e1556ae..79132fb 100644 (file)
@@ -1,8 +1,12 @@
-package # hide from PAUSE 
+package # hide from PAUSE
     DBICTest::Schema::Artist;
 
+use warnings;
+use strict;
+
 use base qw/DBICTest::BaseResult/;
 use Carp qw/confess/;
+use Data::Query::ExprDeclare;
 
 __PACKAGE__->table('artist');
 __PACKAGE__->source_info({
@@ -41,8 +45,11 @@ __PACKAGE__->mk_classdata('field_name_for', {
     name        => 'artist name',
 });
 
+# the undef condition in this rel is *deliberate*
+# tests oddball legacy syntax
 __PACKAGE__->has_many(
-    cds => 'DBICTest::Schema::CD', undef,
+    cds => 'DBICTest::Schema::CD',
+    expr { $_->foreign->artist == $_->self->artistid },
     { order_by => { -asc => 'year'} },
 );
 
@@ -142,6 +149,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) = @_;