Fix inexplicable 5.8.x C3 errors - roll back e6efde04
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Track.pm
CommitLineData
b5c8410c 1package # hide from PAUSE
c6d74d3e 2 DBICTest::Schema::Track;
a02675cd 3
4a233f30 4use warnings;
5use strict;
6
a3a17a15 7use base 'DBICTest::BaseResult';
8use DBICTest::Util 'check_customcond_args';
6fbef4a4 9
c356fcb1 10# The component order is Part of a test,
11# important to remain as-is
a267ea85 12__PACKAGE__->load_components(qw{
13 +DBICTest::DeployComponent
14 InflateColumn::DateTime
15 Ordered
16});
a02675cd 17
ff657a43 18__PACKAGE__->table('track');
19__PACKAGE__->add_columns(
0009fa49 20 'trackid' => {
21 data_type => 'integer',
22 is_auto_increment => 1,
23 },
24 'cd' => {
25 data_type => 'integer',
26 },
27 'position' => {
c1d7087d 28 data_type => 'int',
91b0fbd7 29 accessor => 'pos',
0009fa49 30 },
31 'title' => {
32 data_type => 'varchar',
cb561d1a 33 size => 100,
0009fa49 34 },
43556c5d 35 last_updated_on => {
36 data_type => 'datetime',
37 accessor => 'updated_date',
38 is_nullable => 1
39 },
abc914bd 40 last_updated_at => {
41 data_type => 'datetime',
42 is_nullable => 1
43 },
0009fa49 44);
ff657a43 45__PACKAGE__->set_primary_key('trackid');
46
365d06b7 47__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
48__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
49
1ceafb0c 50__PACKAGE__->position_column ('position');
51__PACKAGE__->grouping_column ('cd');
52
98fcc1c0 53# the undef condition in this rel is *deliberate*
54# tests oddball legacy syntax
97c96475 55__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
56 proxy => { cd_title => 'title' },
57});
8c7c8398 58# custom condition coderef
59__PACKAGE__->belongs_to( cd_cref_cond => 'DBICTest::Schema::CD',
60sub {
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;
65
66 return (
67 {
68 "$args->{foreign_alias}.cdid" => { -ident => "$args->{self_alias}.cd" },
69 },
70
ef0845ba 71 ! $args->{self_result_object} ? () : {
7df2b5df 72 "$args->{foreign_alias}.cdid" => $args->{self_result_object}->get_column('cd')
ef0845ba 73 },
8c7c8398 74
e884e5d9 75 ! $args->{foreign_values} ? () : {
76 "$args->{self_alias}.cd" => $args->{foreign_values}{cdid}
ef0845ba 77 },
8c7c8398 78 );
79}
80);
97c96475 81__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
82 proxy => 'year'
83});
a02675cd 84
a1cb5921 85__PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
4f6386b0 86__PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
a1cb5921 87
18129e81 88__PACKAGE__->belongs_to(
89 "year1999cd",
90 "DBICTest::Schema::Year1999CDs",
98fcc1c0 91 'cd',
f549392f 92 { join_type => 'left' }, # the relationship is of course optional
18129e81 93);
94__PACKAGE__->belongs_to(
95 "year2000cd",
96 "DBICTest::Schema::Year2000CDs",
98fcc1c0 97 'cd',
f549392f 98 { join_type => 'left' },
18129e81 99);
100
bdf6d515 101__PACKAGE__->has_many (
102 next_tracks => __PACKAGE__,
6c4f4d69 103 sub {
6fbef4a4 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 :)
a3a17a15 107 my $args = &check_customcond_args;
6fbef4a4 108
6c4f4d69 109 return (
110 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
111 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
112 },
98def3ef 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 },
6c4f4d69 116 }
117 )
118 }
b5c8410c 119);
120
c200d949 121__PACKAGE__->has_many (
122 deliberately_broken_all_cd_tracks => __PACKAGE__,
123 sub {
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;
128
129 return {
130 "$args->{foreign_alias}.cd" => "$args->{self_alias}.cd"
131 };
132 }
133);
134
a267ea85 135our $hook_cb;
136
137sub sqlt_deploy_hook {
138 my $class = shift;
139
140 $hook_cb->($class, @_) if $hook_cb;
141 $class->next::method(@_) if $class->next::can;
142}
143
a02675cd 1441;