1 package # hide from PAUSE
2 DBICTest::Schema::Track;
4 use base qw/DBICTest::BaseResult/;
7 __PACKAGE__->load_components(qw{
8 +DBICTest::DeployComponent
9 InflateColumn::DateTime
13 __PACKAGE__->table('track');
14 __PACKAGE__->add_columns(
16 data_type => 'integer',
17 is_auto_increment => 1,
20 data_type => 'integer',
27 data_type => 'varchar',
31 data_type => 'datetime',
32 accessor => 'updated_date',
36 data_type => 'datetime',
40 __PACKAGE__->set_primary_key('trackid');
42 __PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
43 __PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
45 __PACKAGE__->position_column ('position');
46 __PACKAGE__->grouping_column ('cd');
49 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
50 proxy => { cd_title => 'title' },
52 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
56 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
57 __PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
59 __PACKAGE__->belongs_to(
61 "DBICTest::Schema::Year1999CDs",
62 { "foreign.cdid" => "self.cd" },
63 { join_type => 'left' }, # the relationship is of course optional
65 __PACKAGE__->belongs_to(
67 "DBICTest::Schema::Year2000CDs",
68 { "foreign.cdid" => "self.cd" },
69 { join_type => 'left' },
72 __PACKAGE__->has_many (
73 next_tracks => __PACKAGE__,
77 # This is for test purposes only. A regular user does not
78 # need to sanity check the passed-in arguments, this is what
79 # the tests are for :)
80 my @missing_args = grep { ! defined $args->{$_} }
81 qw/self_alias foreign_alias self_resultsource foreign_relname/;
82 confess "Required arguments not supplied to custom rel coderef: @missing_args\n"
86 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
87 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
89 $args->{self_rowobj} && {
90 "$args->{foreign_alias}.cd" => $args->{self_rowobj}->get_column('cd'),
91 "$args->{foreign_alias}.position" => { '>' => $args->{self_rowobj}->pos },
99 sub sqlt_deploy_hook {
102 $hook_cb->($class, @_) if $hook_cb;
103 $class->next::method(@_) if $class->next::can;