1 package # hide from PAUSE
2 DBICTest::Schema::Track;
7 use base 'DBICTest::BaseResult';
8 use DBICTest::Util 'check_customcond_args';
10 # The component order is Part of a test,
11 # important to remain as-is
12 __PACKAGE__->load_components(qw{
13 +DBICTest::DeployComponent
14 InflateColumn::DateTime
18 __PACKAGE__->table('track');
19 __PACKAGE__->add_columns(
21 data_type => 'integer',
22 is_auto_increment => 1,
25 data_type => 'integer',
32 data_type => 'varchar',
36 data_type => 'datetime',
37 accessor => 'updated_date',
41 data_type => 'datetime',
45 __PACKAGE__->set_primary_key('trackid');
47 __PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
48 __PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
50 __PACKAGE__->position_column ('position');
51 __PACKAGE__->grouping_column ('cd');
53 # the undef condition in this rel is *deliberate*
54 # tests oddball legacy syntax
55 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
56 proxy => { cd_title => 'title' },
58 # custom condition coderef
59 __PACKAGE__->belongs_to( cd_cref_cond => 'DBICTest::Schema::CD',
61 # This is for test purposes only. A regular user does not
62 # need to sanity check the passed-in arguments, this is what
63 # the tests are for :)
64 my $args = &check_customcond_args;
68 "$args->{foreign_alias}.cdid" => { -ident => "$args->{self_alias}.cd" },
71 ! $args->{self_result_object} ? () : {
72 "$args->{foreign_alias}.cdid" => $args->{self_result_object}->get_column('cd')
75 ! $args->{foreign_values} ? () : {
76 "$args->{self_alias}.cd" => $args->{foreign_values}{cdid}
81 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
85 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
86 __PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
88 __PACKAGE__->belongs_to(
90 "DBICTest::Schema::Year1999CDs",
92 { join_type => 'left' }, # the relationship is of course optional
94 __PACKAGE__->belongs_to(
96 "DBICTest::Schema::Year2000CDs",
98 { join_type => 'left' },
101 __PACKAGE__->has_many (
102 next_tracks => __PACKAGE__,
104 # This is for test purposes only. A regular user does not
105 # need to sanity check the passed-in arguments, this is what
106 # the tests are for :)
107 my $args = &check_customcond_args;
110 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
111 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
113 $args->{self_result_object} && {
114 "$args->{foreign_alias}.cd" => $args->{self_result_object}->get_column('cd'),
115 "$args->{foreign_alias}.position" => { '>' => $args->{self_result_object}->pos },
121 __PACKAGE__->has_many (
122 deliberately_broken_all_cd_tracks => __PACKAGE__,
124 # This is for test purposes only. A regular user does not
125 # need to sanity check the passed-in arguments, this is what
126 # the tests are for :)
127 my $args = &check_customcond_args;
130 "$args->{foreign_alias}.cd" => "$args->{self_alias}.cd"
137 sub sqlt_deploy_hook {
140 $hook_cb->($class, @_) if $hook_cb;
141 $class->next::method(@_) if $class->next::can;