line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
17
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
5
|
2
|
|
|
2
|
|
12
|
use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1298
|
|
6
|
2
|
|
|
2
|
|
23
|
use mro 'c3'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
10
|
|
7
|
2
|
|
|
2
|
|
63
|
use DBIx::Class::Schema::Loader::Utils 'array_eq'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
137
|
|
8
|
2
|
|
|
2
|
|
14
|
use namespace::clean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
22
|
|
9
|
2
|
|
|
2
|
|
606
|
use Lingua::EN::Inflect::Number (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1075
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.07050'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _to_PL { |
14
|
65
|
|
|
65
|
|
189
|
my ($self, $name) = @_; |
15
|
|
|
|
|
|
|
|
16
|
65
|
|
|
|
|
214
|
return Lingua::EN::Inflect::Number::to_PL($name); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _to_S { |
20
|
66
|
|
|
66
|
|
164
|
my ($self, $name) = @_; |
21
|
|
|
|
|
|
|
|
22
|
66
|
|
|
|
|
242
|
return Lingua::EN::Inflect::Number::to_S($name); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
72
|
|
|
72
|
|
466
|
sub _default_relationship_attrs { +{} } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _relnames_and_method { |
28
|
7
|
|
|
7
|
|
26
|
my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
7
|
|
|
|
|
17
|
my $remote_moniker = $rel->{remote_source}; |
31
|
7
|
|
|
|
|
23
|
my $remote_obj = $self->{schema}->source( $remote_moniker ); |
32
|
7
|
|
|
|
|
329
|
my $remote_class = $self->{schema}->class( $remote_moniker ); |
33
|
7
|
|
|
|
|
533
|
my $local_relname = $self->_local_relname( $rel->{remote_table}, $cond); |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
25
|
my $local_cols = $rel->{local_columns}; |
36
|
7
|
|
|
|
|
22
|
my $local_table = $rel->{local_table}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# If more than one rel between this pair of tables, use the local |
39
|
|
|
|
|
|
|
# col names to distinguish |
40
|
7
|
|
|
|
|
18
|
my ($remote_relname, $remote_relname_uninflected); |
41
|
7
|
100
|
|
|
|
26
|
if ( $counters->{$remote_moniker} > 1) { |
42
|
2
|
|
|
|
|
14
|
my $colnames = lc(q{_} . join(q{_}, map lc($_), @$local_cols)); |
43
|
2
|
50
|
|
|
|
10
|
$local_relname .= $colnames if keys %$cond > 1; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
10
|
$remote_relname = lc($local_table) . $colnames; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
7
|
$remote_relname_uninflected = $remote_relname; |
48
|
2
|
|
|
|
|
10
|
($remote_relname) = $self->_inflect_plural( $remote_relname ); |
49
|
|
|
|
|
|
|
} else { |
50
|
5
|
|
|
|
|
22
|
$remote_relname_uninflected = lc $local_table; |
51
|
5
|
|
|
|
|
14
|
($remote_relname) = $self->_inflect_plural(lc $local_table); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
7
|
|
|
|
|
10610
|
my $remote_method = 'has_many'; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# If the local columns have a UNIQUE constraint, this is a one-to-one rel |
57
|
7
|
|
|
|
|
39
|
my $local_source = $self->{schema}->source($local_moniker); |
58
|
7
|
100
|
66
|
|
|
375
|
if (array_eq([ $local_source->primary_columns ], $local_cols) || |
59
|
2
|
|
|
|
|
15
|
grep { array_eq($_->[1], $local_cols) } @$uniqs) { |
60
|
1
|
|
|
|
|
6
|
$remote_method = 'might_have'; |
61
|
1
|
|
|
|
|
7
|
($remote_relname) = $self->_inflect_singular($remote_relname_uninflected); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
2521
|
return ( $local_relname, $remote_relname, $remote_method ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05 - RelBuilder for |
70
|
|
|
|
|
|
|
compatibility with DBIx::Class::Schema::Loader version 0.05003 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
See L and |
75
|
|
|
|
|
|
|
L. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
See L. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
84
|
|
|
|
|
|
|
the same terms as Perl itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |