Extend proxy rel attr
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Track.pm
1 package # hide from PAUSE 
2     DBICTest::Schema::Track;
3
4 use base qw/DBICTest::BaseResult/;
5 __PACKAGE__->load_components(qw/InflateColumn::DateTime Ordered/);
6
7 __PACKAGE__->table('track');
8 __PACKAGE__->add_columns(
9   'trackid' => {
10     data_type => 'integer',
11     is_auto_increment => 1,
12   },
13   'cd' => {
14     data_type => 'integer',
15   },
16   'position' => {
17     data_type => 'int',
18     accessor => 'pos',
19   },
20   'title' => {
21     data_type => 'varchar',
22     size      => 100,
23   },
24   last_updated_on => {
25     data_type => 'datetime',
26     accessor => 'updated_date',
27     is_nullable => 1
28   },
29   last_updated_at => {
30     data_type => 'datetime',
31     is_nullable => 1
32   },
33   small_dt => { # for mssql and sybase DT tests
34     data_type => 'smalldatetime',
35     is_nullable => 1
36   },
37 );
38 __PACKAGE__->set_primary_key('trackid');
39
40 __PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
41 __PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
42
43 __PACKAGE__->position_column ('position');
44 __PACKAGE__->grouping_column ('cd');
45
46
47 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
48     proxy => { cd_title => 'title' },
49 });
50 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
51     proxy => 'year'
52 });
53
54 __PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
55 __PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
56
57 __PACKAGE__->belongs_to(
58     "year1999cd",
59     "DBICTest::Schema::Year1999CDs",
60     { "foreign.cdid" => "self.cd" },
61     { join_type => 'left' },  # the relationship is of course optional
62 );
63 __PACKAGE__->belongs_to(
64     "year2000cd",
65     "DBICTest::Schema::Year2000CDs",
66     { "foreign.cdid" => "self.cd" },
67     { join_type => 'left' },
68 );
69
70 1;