1 package # hide from PAUSE
2 DBICTest::Schema::Track;
7 use base 'DBICTest::BaseResult';
8 use DBICTest::Util 'check_customcond_args';
10 __PACKAGE__->load_components(qw{
11 +DBICTest::DeployComponent
12 InflateColumn::DateTime
16 __PACKAGE__->table('track');
17 __PACKAGE__->add_columns(
19 data_type => 'integer',
20 is_auto_increment => 1,
23 data_type => 'integer',
30 data_type => 'varchar',
34 data_type => 'datetime',
35 accessor => 'updated_date',
39 data_type => 'datetime',
43 __PACKAGE__->set_primary_key('trackid');
45 __PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
46 __PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
48 __PACKAGE__->position_column ('position');
49 __PACKAGE__->grouping_column ('cd');
51 # the undef condition in this rel is *deliberate*
52 # tests oddball legacy syntax
53 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
54 proxy => { cd_title => 'title' },
56 # custom condition coderef
57 __PACKAGE__->belongs_to( cd_cref_cond => 'DBICTest::Schema::CD',
59 # This is for test purposes only. A regular user does not
60 # need to sanity check the passed-in arguments, this is what
61 # the tests are for :)
62 my $args = &check_customcond_args;
66 "$args->{foreign_alias}.cdid" => { -ident => "$args->{self_alias}.cd" },
69 ( $args->{self_resultobj} ? {
70 "$args->{foreign_alias}.cdid" => $args->{self_resultobj}->cd
73 ( $args->{foreign_resultobj} ? {
74 "$args->{self_alias}.cd" => $args->{foreign_resultobj}->cdid
79 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
83 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
84 __PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
86 __PACKAGE__->belongs_to(
88 "DBICTest::Schema::Year1999CDs",
90 { join_type => 'left' }, # the relationship is of course optional
92 __PACKAGE__->belongs_to(
94 "DBICTest::Schema::Year2000CDs",
96 { join_type => 'left' },
99 __PACKAGE__->has_many (
100 next_tracks => __PACKAGE__,
102 # This is for test purposes only. A regular user does not
103 # need to sanity check the passed-in arguments, this is what
104 # the tests are for :)
105 my $args = &check_customcond_args;
108 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
109 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
111 $args->{self_rowobj} && {
112 "$args->{foreign_alias}.cd" => $args->{self_rowobj}->get_column('cd'),
113 "$args->{foreign_alias}.position" => { '>' => $args->{self_rowobj}->pos },
121 sub sqlt_deploy_hook {
124 $hook_cb->($class, @_) if $hook_cb;
125 $class->next::method(@_) if $class->next::can;