X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FArtist.pm;h=79132fb166e598a2f1936aa58c3c5b1a7dcb1102;hb=refs%2Fheads%2Fcurrent%2Fdq;hp=34532dc8efd459ceb7516a5a8c885f80b393b057;hpb=98fcc1c08b73df1c66c41fb4cc736e824e9e4026;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 34532dc..79132fb 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -6,6 +6,7 @@ use strict; use base qw/DBICTest::BaseResult/; use Carp qw/confess/; +use Data::Query::ExprDeclare; __PACKAGE__->table('artist'); __PACKAGE__->source_info({ @@ -47,7 +48,8 @@ __PACKAGE__->mk_classdata('field_name_for', { # 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'} }, ); @@ -147,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) = @_;