Fix all invocations of _resolve_condition to match the new signature
[dbsrgits/DBIx-Class-Historic.git] / t / lib / DBICTest / Schema / Track.pm
CommitLineData
b5c8410c 1package # hide from PAUSE
c6d74d3e 2 DBICTest::Schema::Track;
a02675cd 3
660cf1be 4use base qw/DBICTest::BaseResult/;
6fbef4a4 5use Carp qw/confess/;
6
a267ea85 7__PACKAGE__->load_components(qw{
8 +DBICTest::DeployComponent
9 InflateColumn::DateTime
10 Ordered
11});
a02675cd 12
ff657a43 13__PACKAGE__->table('track');
14__PACKAGE__->add_columns(
0009fa49 15 'trackid' => {
16 data_type => 'integer',
17 is_auto_increment => 1,
18 },
19 'cd' => {
20 data_type => 'integer',
21 },
22 'position' => {
c1d7087d 23 data_type => 'int',
91b0fbd7 24 accessor => 'pos',
0009fa49 25 },
26 'title' => {
27 data_type => 'varchar',
cb561d1a 28 size => 100,
0009fa49 29 },
43556c5d 30 last_updated_on => {
31 data_type => 'datetime',
32 accessor => 'updated_date',
33 is_nullable => 1
34 },
abc914bd 35 last_updated_at => {
36 data_type => 'datetime',
37 is_nullable => 1
38 },
0009fa49 39);
ff657a43 40__PACKAGE__->set_primary_key('trackid');
41
365d06b7 42__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
43__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
44
1ceafb0c 45__PACKAGE__->position_column ('position');
46__PACKAGE__->grouping_column ('cd');
47
48
97c96475 49__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, {
50 proxy => { cd_title => 'title' },
51});
52__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd', {
53 proxy => 'year'
54});
a02675cd 55
a1cb5921 56__PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
4f6386b0 57__PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
a1cb5921 58
18129e81 59__PACKAGE__->belongs_to(
60 "year1999cd",
61 "DBICTest::Schema::Year1999CDs",
62 { "foreign.cdid" => "self.cd" },
f549392f 63 { join_type => 'left' }, # the relationship is of course optional
18129e81 64);
65__PACKAGE__->belongs_to(
66 "year2000cd",
67 "DBICTest::Schema::Year2000CDs",
68 { "foreign.cdid" => "self.cd" },
f549392f 69 { join_type => 'left' },
18129e81 70);
71
bdf6d515 72__PACKAGE__->has_many (
73 next_tracks => __PACKAGE__,
6c4f4d69 74 sub {
75 my $args = shift;
6fbef4a4 76
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"
83 if @missing_args;
84
6c4f4d69 85 return (
86 { "$args->{foreign_alias}.cd" => { -ident => "$args->{self_alias}.cd" },
87 "$args->{foreign_alias}.position" => { '>' => { -ident => "$args->{self_alias}.position" } },
88 },
89 $args->{self_rowobj} && {
1327f050 90 "$args->{foreign_alias}.cd" => $args->{self_rowobj}->get_column('cd'),
91 "$args->{foreign_alias}.position" => { '>' => $args->{self_rowobj}->pos },
6c4f4d69 92 }
93 )
94 }
b5c8410c 95);
96
a267ea85 97our $hook_cb;
98
99sub sqlt_deploy_hook {
100 my $class = shift;
101
102 $hook_cb->($class, @_) if $hook_cb;
103 $class->next::method(@_) if $class->next::can;
104}
105
a02675cd 1061;