1 package # hide from PAUSE
2 DBICTest::Schema::Track;
4 use base qw/DBICTest::BaseResult/;
7 __PACKAGE__->load_components(qw/InflateColumn::DateTime Ordered/);
9 __PACKAGE__->table('track');
10 __PACKAGE__->add_columns(
12 data_type => 'integer',
13 is_auto_increment => 1,
16 data_type => 'integer',
23 data_type => 'varchar',
27 data_type => 'datetime',
28 accessor => 'updated_date',
32 data_type => 'datetime',
36 __PACKAGE__->set_primary_key('trackid');
38 __PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
39 __PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
41 __PACKAGE__->position_column ('position');
42 __PACKAGE__->grouping_column ('cd');
45 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
46 proxy => { cd_title => 'title' },
48 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
52 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
53 __PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
55 __PACKAGE__->belongs_to(
57 "DBICTest::Schema::Year1999CDs",
58 { "foreign.cdid" => "self.cd" },
59 { join_type => 'left' }, # the relationship is of course optional
61 __PACKAGE__->belongs_to(
63 "DBICTest::Schema::Year2000CDs",
64 { "foreign.cdid" => "self.cd" },
65 { join_type => 'left' },
68 __PACKAGE__->might_have (
69 next_track => __PACKAGE__,
73 # This is for test purposes only. A regular user does not
74 # need to sanity check the passed-in arguments, this is what
75 # the tests are for :)
76 my @missing_args = grep { ! defined $args->{$_} }
77 qw/self_alias foreign_alias self_resultsource foreign_relname/;
78 confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
82 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
83 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
85 $args->{self_rowobj} && {
86 "$args->{foreign_alias}.cd" => $args->{self_rowobj}->cd,
87 "$args->{foreign_alias}.position" => { '>' => $args->{self_rowobj}->position },