Add torture of limiting subselect with non-root table selection renamer
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artwork_to_Artist.pm
CommitLineData
d5633096 1package # hide from PAUSE
2 DBICTest::Schema::Artwork_to_Artist;
3
660cf1be 4use base qw/DBICTest::BaseResult/;
6fbef4a4 5use Carp qw/confess/;
d5633096 6
7__PACKAGE__->table('artwork_to_artist');
8__PACKAGE__->add_columns(
9 'artwork_cd_id' => {
10 data_type => 'integer',
11 is_foreign_key => 1,
12 },
13 'artist_id' => {
14 data_type => 'integer',
15 is_foreign_key => 1,
16 },
17);
18__PACKAGE__->set_primary_key(qw/artwork_cd_id artist_id/);
19__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_cd_id');
20__PACKAGE__->belongs_to('artist', 'DBICTest::Schema::Artist', 'artist_id');
21
e98e6478 22__PACKAGE__->belongs_to('artist_test_m2m', 'DBICTest::Schema::Artist',
6fbef4a4 23 sub {
24 my $args = shift;
25
26 # This is for test purposes only. A regular user does not
27 # need to sanity check the passed-in arguments, this is what
28 # the tests are for :)
29 my @missing_args = grep { ! defined $args->{$_} }
30 qw/self_alias foreign_alias self_resultsource foreign_relname/;
31 confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
32 if @missing_args;
33
34 return (
35 { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
36 "$args->{foreign_alias}.rank" => { '<' => 10 },
37 },
38 $args->{self_rowobj} && {
39 "$args->{foreign_alias}.artistid" => $args->{self_rowobj}->artist_id,
40 "$args->{foreign_alias}.rank" => { '<' => 10 },
41 }
42 );
43 }
44);
e98e6478 45
46__PACKAGE__->belongs_to('artist_test_m2m_noopt', 'DBICTest::Schema::Artist',
6fbef4a4 47 sub {
48 my $args = shift;
49
50 # This is for test purposes only. A regular user does not
51 # need to sanity check the passed-in arguments, this is what
52 # the tests are for :)
53 my @missing_args = grep { ! defined $args->{$_} }
54 qw/self_alias foreign_alias self_resultsource foreign_relname/;
55 confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
56 if @missing_args;
57
58 return (
59 { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
60 "$args->{foreign_alias}.rank" => { '<' => 10 },
61 }
62 );
63 }
64);
e98e6478 65
d5633096 661;