Multiple common sense fixes for m2m accessors
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artwork_to_Artist.pm
CommitLineData
d5633096 1package # hide from PAUSE
2 DBICTest::Schema::Artwork_to_Artist;
4a233f30 3
4use warnings;
5use strict;
d5633096 6
a3a17a15 7use base 'DBICTest::BaseResult';
8use DBICTest::Util 'check_customcond_args';
d5633096 9
10__PACKAGE__->table('artwork_to_artist');
11__PACKAGE__->add_columns(
12 'artwork_cd_id' => {
13 data_type => 'integer',
14 is_foreign_key => 1,
15 },
16 'artist_id' => {
17 data_type => 'integer',
18 is_foreign_key => 1,
19 },
20);
21__PACKAGE__->set_primary_key(qw/artwork_cd_id artist_id/);
22__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_cd_id');
23__PACKAGE__->belongs_to('artist', 'DBICTest::Schema::Artist', 'artist_id');
24
2f7d81b4 25__PACKAGE__->belongs_to('artist_limited_rank', 'DBICTest::Schema::Artist',
6fbef4a4 26 sub {
6fbef4a4 27 # This is for test purposes only. A regular user does not
28 # need to sanity check the passed-in arguments, this is what
29 # the tests are for :)
a3a17a15 30 my $args = &check_customcond_args;
6fbef4a4 31
32 return (
33 { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
34 "$args->{foreign_alias}.rank" => { '<' => 10 },
35 },
12d4ace4 36 !$args->{self_result_object} ? () : {
98def3ef 37 "$args->{foreign_alias}.artistid" => $args->{self_result_object}->artist_id,
6fbef4a4 38 "$args->{foreign_alias}.rank" => { '<' => 10 },
12d4ace4 39 },
40 !$args->{foreign_values} ? () : {
41 "$args->{self_alias}.artist_id" => $args->{foreign_values}{artistid},
42 },
6fbef4a4 43 );
44 }
45);
e98e6478 46
2f7d81b4 47__PACKAGE__->belongs_to('artist_limited_rank_opaque', 'DBICTest::Schema::Artist',
6fbef4a4 48 sub {
6fbef4a4 49 # This is for test purposes only. A regular user does not
50 # need to sanity check the passed-in arguments, this is what
51 # the tests are for :)
a3a17a15 52 my $args = &check_customcond_args;
6fbef4a4 53
54 return (
55 { "$args->{foreign_alias}.artistid" => { -ident => "$args->{self_alias}.artist_id" },
56 "$args->{foreign_alias}.rank" => { '<' => 10 },
57 }
58 );
59 }
60);
e98e6478 61
d5633096 621;