| 1 | package DBIx::Class::ResultDDL; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # capture the default values of $^H and $^W for this version of Perl | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | BEGIN { $DBIx::Class::ResultDDL::_default_h= $^H; $DBIx::Class::ResultDDL::_default_w= $^W; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use Exporter::Extensible -exporter_setup => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use B::Hooks::EndOfScope 'on_scope_end'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Sugar methods for declaring DBIx::Class::Result data definitions | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | our $VERSION = '2.04'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | our $CALLER; # can be used localized to wrap caller context into an anonymous sub | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 47 | ▶ | sub swp :Export(-) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
swp: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 47 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 47 | ▶ | require strict; strict->import if $^H == $DBIx::Class::ResultDDL::_default_h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 47 | ▶ | require warnings; warnings->import if $^W == $DBIx::Class::ResultDDL::_default_w; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 47 | $self->_inherit_dbic; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 59 | ▶ | sub _inherit_dbic { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inherit_dbic: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 59 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 59 | my $pkg= $self->{into}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 59 | ▶ | unless ($pkg->can('load_components') && $pkg->can('add_column')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pkg->can("load_components") and $pkg->can("add_column")
MC/DC50%1/2
$pkg->can("load_components") and $pkg->can("add_column")
$pkg->can("load_components")
$pkg->can("add_column")
Truth table66%2/3
A and B
A= $pkg->can("load_components")B= $pkg->can("add_column")
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 35 | require DBIx::Class::Core; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 35 | push @{ $pkg . '::ISA' }, 'DBIx::Class::Core'; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | our $DISABLE_AUTOCLEAN; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 47 | ▶ | sub autoclean :Export(-) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoclean: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 47 | ▶ | return if $DISABLE_AUTOCLEAN; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 41 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 41 | my $sref= $self->exporter_config_scope; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 41 | ▶ | $self->exporter_config_scope($sref= \my $x) unless $sref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 41 | ▶ | on_scope_end { $$sref->clean }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | ▶ | sub V2 :Export(-) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
V2: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 23 | shift->exporter_also_import('-swp',':V2','-autoclean'); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | sub exporter_autoload_symbol { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exporter_autoload_symbol: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | my ($self, $sym)= @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | ▶ | if ($sym =~ /^-V([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | my $tag= ":V$1"; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | my $method= sub { shift->exporter_also_import('-swp',$tag,'-autoclean') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | return $self->exporter_register_option("V$1", $method); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # The functions and tag list for previous versions are not loaded by default. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # They are contained in a separate package ::V$N, which inherits many methods | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # from this one but then overrides all the ones whose API were different in | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # the past version. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # In order to make those versions exportable, they have to be loaded into | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # the cache or symbol table of this package before they can be added to a tag | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # to get exported. This also requires that they be given a different name | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # The pattern used here is to prefix "v0_" and so on to the methods which | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # are re-defined in the subclass. | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | sub exporter_autoload_tag { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exporter_autoload_tag: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 8 | my ($self, $name)= @_; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 8 | ▶ | my $class= ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | ▶ | if ($name =~ /^V([0-9]+)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | my $v_pkg= "DBIx::Class::ResultDDL::$name"; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | my $v= $1; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | eval "require $v_pkg" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | or croak "Can't load package $v_pkg: $@"; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 8 | my $ver_exports= $v_pkg->exporter_get_tag($name); | |||||||||||||||||||||||||||||||||||||||||
| 72 | # For each tag member, see if it is the same as the method in this class. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | # If not, bring it in as v${X}_${name} and then export { -as => $name } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 8 | my @tag; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | for (@$ver_exports) { | |||||||||||||||||||||||||||||||||||||||||
| 76 | 442 | ▶ | if ($class->can($_) == $v_pkg->can($_)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 360 | push @tag, $_; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 82 | my $install_as= "v${v}_$_"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 82 | $class->exporter_export($install_as => $v_pkg->can($_)); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 82 | push @tag, $install_as, { -as => $_ }; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | return \@tag; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | our %_settings_for_package; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 61 | ▶ | sub _settings_for_package { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_settings_for_package: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 61 | ▶ | return $_settings_for_package{shift()} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$DBIx::Class::ResultDDL::_settings_for_package{shift()} ||= {}
MC/DC100%1/1
$DBIx::Class::ResultDDL::_settings_for_package{shift()} ||= {}
$DBIx::Class::ResultDDL::_settings_for_package{shift()}
Truth table100%2/2
A
A= $DBIx::Class::ResultDDL::_settings_for_package{shift()}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 10 | ▶ | sub enable_inflate_datetime :Export(-inflate_datetime) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_inflate_datetime: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 10 | $self->_inherit_dbic; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 10 | my $pkg= $self->{into}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | $pkg->load_components('InflateColumn::DateTime') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | unless $pkg->isa('DBIx::Class::InflateColumn::DateTime'); | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 10 | _settings_for_package($pkg)->{inflate_datetime}= 1; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub enable_inflate_json :Export(-inflate_json) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_inflate_json: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | $self->_inherit_dbic; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | my $pkg= $self->{into}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | $pkg->load_components('InflateColumn::Serializer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | unless $pkg->isa('DBIx::Class::InflateColumn::Serializer'); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | my $settings= _settings_for_package($pkg); | |||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | $settings->{inflate_json}= 1; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $settings->{json_defaults}{serializer_class}= 'JSON'; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub enable_retrieve_defaults :Export(-retrieve_defaults) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_retrieve_defaults: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | my $self= shift; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | my $pkg= $self->{into}; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | _settings_for_package($pkg)->{retrieve_defaults}= 1; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | my @V2= qw( | |||||||||||||||||||||||||||||||||||||||||
| 125 | table view | ||||||||||||||||||||||||||||||||||||||||||
| 126 | col | ||||||||||||||||||||||||||||||||||||||||||
| 127 | null default auto_inc fk | ||||||||||||||||||||||||||||||||||||||||||
| 128 | integer unsigned tinyint smallint bigint decimal numeric money | ||||||||||||||||||||||||||||||||||||||||||
| 129 | float float4 float8 double real | ||||||||||||||||||||||||||||||||||||||||||
| 130 | char varchar nchar nvarchar MAX binary varbinary bit varbit | ||||||||||||||||||||||||||||||||||||||||||
| 131 | blob tinyblob mediumblob longblob text tinytext mediumtext longtext ntext bytea | ||||||||||||||||||||||||||||||||||||||||||
| 132 | date datetime timestamp enum bool boolean | ||||||||||||||||||||||||||||||||||||||||||
| 133 | uuid json jsonb inflate_json array | ||||||||||||||||||||||||||||||||||||||||||
| 134 | primary_key idx create_index unique sqlt_add_index sqlt_add_constraint | ||||||||||||||||||||||||||||||||||||||||||
| 135 | rel_one rel_many has_one might_have has_many belongs_to many_to_many | ||||||||||||||||||||||||||||||||||||||||||
| 136 | ddl_cascade dbic_cascade | ||||||||||||||||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 8 | our %EXPORT_TAGS; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 8 | $EXPORT_TAGS{V2}= \@V2; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 8 | export @V2; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 39 | ▶ | sub table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 39 | my $name= shift; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 39 | ▶ | DBIx::Class::Core->can('table')->(scalar($CALLER||caller), $name); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 133 | ▶ | sub col { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
col: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 133 | my $name= shift; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 133 | ▶ | croak "Odd number of arguments for col(): (".join(',',@_).")" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | if scalar(@_) & 1; | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 133 | ▶ | my $pkg= $CALLER || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 133 | $pkg->add_column($name, expand_col_options($pkg, @_)); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 133 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | sub expand_col_options; | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 124 | ▶ | sub _maybe_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_array: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 124 | my @dims; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 124 | ▶ | while (@_ && ref $_[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and ref $_[0] eq "ARRAY"
MC/DC100%2/2
@_ and ref $_[0] eq "ARRAY"
@_
ref $_[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @_B= ref $_[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | my $array= shift @_; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | push @dims, @$array? @$array : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 124 | join '', map "[$_]", @dims | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 19 | ▶ | sub _maybe_size { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_size: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 19 | ▶ | return shift if @_ && Scalar::Util::looks_like_number($_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and &Scalar::Util::looks_like_number($_[0])
MC/DC100%2/2
@_ and &Scalar::Util::looks_like_number($_[0])
@_
&Scalar::Util::looks_like_number($_[0])
Truth table100%3/3
A and B
A= @_B= &Scalar::Util::looks_like_number($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 44 | ▶ | sub _maybe_size_or_max { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_size_or_max: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 44 | ▶ | return shift if @_ && (Scalar::Util::looks_like_number($_[0]) || uc($_[0]) eq 'MAX'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@_ and &Scalar::Util::looks_like_number($_[0]) || uc $_[0] eq "MAX"
&Scalar::Util::looks_like_number($_[0]) or uc $_[0] eq "MAX"
MC/DC33%1/3
@_ and &Scalar::Util::looks_like_number($_[0]) || uc $_[0] eq "MAX"
@_
&Scalar::Util::looks_like_number($_[0])
uc $_[0] eq "MAX"
Truth table75%3/4
A and B or C
A= @_B= &Scalar::Util::looks_like_number($_[0])C= uc $_[0] eq "MAX"
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 23 | ▶ | sub _maybe_timezone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_timezone: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | # This is a weak check, but assume the timezone will have at least one capital letter, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # and that DBIC column attribute names will not. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 23 | ▶ | return shift if @_ && !ref $_[0] && $_[0] =~ /(^floating$|^local$|[A-Z])/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@_ and not ref $_[0] and $_[0] =~ /(^floating$|^local$|[A-Z])/
@_ and not ref $_[0]
MC/DC66%2/3
@_ and not ref $_[0] and $_[0] =~ /(^floating$|^local$|[A-Z])/
@_
not ref $_[0]
$_[0] =~ /(^floating$|^local$|[A-Z])/
Truth table75%3/4
A and not(B) and C
A= @_B= not ref $_[0]C= $_[0] =~ /(^floating$|^local$|[A-Z])/
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 15 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 27 | ▶ | sub null { is_nullable => 1, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
null: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | ▶ | sub auto_inc { is_auto_increment => 1, 'extra.auto_increment_type' => 'monotonic', @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_inc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | ▶ | sub fk { is_foreign_key => 1, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fk: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 17 | ▶ | sub default { default_value => (@_ > 1? [ @_ ] : $_[0]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 22 | ▶ | sub integer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
integer: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 22 | ▶ | my $size= shift if @_ && Scalar::Util::looks_like_number($_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and &Scalar::Util::looks_like_number($_[0])
MC/DC0%0/2
@_ and &Scalar::Util::looks_like_number($_[0])
@_
&Scalar::Util::looks_like_number($_[0])
Truth table66%2/3
A and B
A= @_B= &Scalar::Util::looks_like_number($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 22 | ▶ | data_type => 'integer'.&_maybe_array, size => $size || 11, @_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | sub unsigned { 'extra.unsigned' => 1, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unsigned: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | sub tinyint { data_type => 'tinyint', size => 4, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tinyint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | sub smallint { data_type => 'smallint', size => 6, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smallint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | sub bigint { data_type => 'bigint', size => 22, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bigint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | sub decimal { _numeric(decimal => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decimal: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | ▶ | sub numeric { _numeric(numeric => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numeric: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 5 | ▶ | sub _numeric { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_numeric: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | my $type= shift; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | my $precision= &_maybe_size; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | my $size; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | ▶ | if (defined $precision) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | my $scale= &_maybe_size; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | ▶ | $size= defined $scale? [ $precision, $scale ] : [ $precision ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 5 | ▶ | return data_type => $type.&_maybe_array, ($size? ( size => $size ) : ()), @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub money { data_type => 'money'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
money: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub double { data_type => 'double precision'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
double: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | ▶ | sub float8 { data_type => 'float8'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float8: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub real { data_type => 'real'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
real: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | sub float4 { data_type => 'float4'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float4: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | # the float used by SQL Server allows variable size spec as number of bits of mantissa | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | sub float { my $size= &_maybe_size; data_type => 'float'.&_maybe_array, (defined $size? (size => $size) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | sub char { my $size= &_maybe_size; data_type => 'char'.&_maybe_array, size => $size || 1, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
char: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | ▶ | sub nchar { my $size= &_maybe_size; data_type => 'nchar'.&_maybe_array, size => $size || 1, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nchar: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 30 | ▶ | sub varchar { my $size= &_maybe_size_or_max; data_type => 'varchar'.&_maybe_array, size => $size, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
varchar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | ▶ | sub nvarchar { my $size= &_maybe_size_or_max; data_type => 'nvarchar'.&_maybe_array, size => $size, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nvarchar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub binary { my $size= &_maybe_size_or_max; data_type => 'binary'.&_maybe_array, size => $size, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub varbinary { my $size= &_maybe_size_or_max; data_type => 'varbinary'.&_maybe_array, size => $size, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
varbinary: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | sub bit { my $size= &_maybe_size; data_type => 'bit'.&_maybe_array, size => (defined $size? $size : 1), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bit: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | sub varbit { my $size= &_maybe_size; data_type => 'varbit'.&_maybe_array, (defined $size? (size => $size) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
varbit: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | sub MAX { 'MAX' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MAX: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # postgres blob type | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub bytea { data_type => 'bytea'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bytea: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # These aren't valid for Postgres, so no array notation needed | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | sub blob { my $size= &_maybe_size; data_type => 'blob', (defined $size? (size => $size) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blob: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub tinyblob { data_type => 'tinyblob', size => 0xFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tinyblob: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub mediumblob { data_type => 'mediumblob',size => 0xFFFFFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mediumblob: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub longblob { data_type => 'longblob', size => 0xFFFFFFFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
longblob: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | ▶ | sub text { my $size= &_maybe_size_or_max; data_type => 'text'.&_maybe_array, (defined $size? (size => $size) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub ntext { my $size= &_maybe_size_or_max; data_type => 'ntext', size => ($size || 0x3FFFFFFF), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ntext: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub tinytext { data_type => 'tinytext', size => 0xFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tinytext: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub mediumtext { data_type => 'mediumtext',size => 0xFFFFFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mediumtext: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub longtext { data_type => 'longtext', size => 0xFFFFFFFF, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
longtext: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub enum { data_type => 'enum', 'extra.list' => [ @_ ]} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enum: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub boolean { data_type => 'boolean'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
boolean: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub bool { data_type => 'boolean'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bool: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | ▶ | sub date { data_type => 'date'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 20 | ▶ | sub datetime { my $tz= &_maybe_timezone; data_type => 'datetime'.&_maybe_array, ($tz? (timezone => $tz) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
datetime: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | sub timestamp { my $tz= &_maybe_timezone; data_type => 'timestamp'.&_maybe_array,($tz? (timezone => $tz) : ()), @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timestamp: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | ▶ | sub array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: called CC=9 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | # If one argument and the argument is a string, then it is a type name | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | if (@_ == 1 && $_[0] && !ref $_[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@_ == 1 and $_[0] and not ref $_[0]
@_ == 1 and $_[0]
MC/DC33%1/3
@_ == 1 and $_[0] and not ref $_[0]
@_ == 1
$_[0]
not ref $_[0]
Truth table50%2/4
A and B and not(C)
A= @_ == 1B= $_[0]C= not ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | return data_type => $_[0] . '[]'; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # Else, scan through argument list looking for data_type, and append [] to following item. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | my $data_type_idx; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | for (my $i= 0; $i < @_; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 6 | ▶ | $data_type_idx= $i+1 if $_[$i] eq 'data_type' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | $data_type_idx && $_[$data_type_idx] && !ref $_[$data_type_idx] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$data_type_idx and $_[$data_type_idx] and not ref $_[$data_type_idx]
$data_type_idx and $_[$data_type_idx]
MC/DC0%0/3
$data_type_idx and $_[$data_type_idx] and not ref $_[$data_type_idx]
$data_type_idx
$_[$data_type_idx]
not ref $_[$data_type_idx]
Truth table25%1/4
A and B and not(C)
A= $data_type_idxB= $_[$data_type_idx]C= not ref $_[$data_type_idx]
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | or die 'array needs a type'; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | $_[$data_type_idx] .= '[]'; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | return @_; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | sub uuid { data_type => 'uuid'.&_maybe_array, @_ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | # This is a generator that includes the json_args into the installed method. | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 10 | ▶ | sub json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 10 | ▶ | my $pkg= ($CALLER||caller); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 10 | my $defaults= _settings_for_package($pkg)->{json_defaults}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 10 | ▶ | return data_type => 'json'.&_maybe_array, ($defaults? %$defaults : ()), @_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | sub jsonb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
jsonb: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | my $pkg= ($CALLER||caller); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | my $defaults= _settings_for_package($pkg)->{json_defaults}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | return data_type => 'jsonb'.&_maybe_array, ($defaults? %$defaults : ()), @_ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 3 | ▶ | sub inflate_json { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_json: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | ▶ | my $pkg= ($CALLER||caller); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 3 | ▶ | $pkg->load_components('InflateColumn::Serializer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | unless $pkg->isa('DBIx::Class::InflateColumn::Serializer'); | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | return serializer_class => 'JSON', @_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 21 | ▶ | sub primary_key { ($CALLER||caller)->set_primary_key(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
primary_key: called CC=2 SCAR=9.2
Pod
documented
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | sub unique { ($CALLER||caller)->add_unique_constraint(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unique: called CC=2 SCAR=9.2
Pod
documented
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | sub rel_one { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rel_one: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | _add_rel(scalar($CALLER||caller), 'rel_one', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | sub rel_many { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rel_many: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | _add_rel(scalar($CALLER||caller), 'rel_many', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | ▶ | sub might_have { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
might_have: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | ▶ | _add_rel(scalar($CALLER||caller), 'might_have', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub has_one { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_one: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | _add_rel(scalar($CALLER||caller), 'has_one', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table0%0/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | ▶ | sub has_many { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_many: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | ▶ | _add_rel(scalar($CALLER||caller), 'has_many', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 3 | ▶ | sub belongs_to { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
belongs_to: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | ▶ | _add_rel(scalar($CALLER||caller), 'belongs_to', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub many_to_many { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
many_to_many: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | DBIx::Class::Core->can('many_to_many')->(scalar($CALLER||caller), @_); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table0%0/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | sub expand_relationship_params; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 12 | ▶ | sub _add_rel { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_rel: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 12 | my ($pkg, $reltype, $relname, $rel_pkg, $dbic_colmap, $opts)= &expand_relationship_params; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 12 | ▶ | if ($reltype eq 'rel_one' || $reltype eq 'rel_many') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$reltype eq "rel_one" or $reltype eq "rel_many"
MC/DC100%2/2
$reltype eq "rel_one" or $reltype eq "rel_many"
$reltype eq "rel_one"
$reltype eq "rel_many"
Truth table100%3/3
A or B
A= $reltype eq "rel_one"B= $reltype eq "rel_many"
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | # Are we referring to the foreign row's primary key? DBIC load order might not have | ||||||||||||||||||||||||||||||||||||||||||
| 330 | # gotten there yet, so take a guess that if it isn't a part of our primary key, then it | ||||||||||||||||||||||||||||||||||||||||||
| 331 | # is a part of their primary key. | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | my $is_f_key; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 3 | ▶ | if (ref $dbic_colmap eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | my @pk= $pkg->primary_columns; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | ▶ | $is_f_key= !grep { defined $dbic_colmap->{$_} || defined $dbic_colmap->{"self.$_"} } @pk; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $dbic_colmap->{$_} || defined $$dbic_colmap{"self.$_"}
MC/DC0%0/2
defined $dbic_colmap->{$_} || defined $$dbic_colmap{"self.$_"}
defined $dbic_colmap->{$_}
defined $$dbic_colmap{"self.$_"}
Truth table33%1/3
A || B
A= defined $dbic_colmap->{$_}B= defined $$dbic_colmap{"self.$_"}
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | $pkg->add_relationship( | ||||||||||||||||||||||||||||||||||||||||||
| 339 | $relname, | ||||||||||||||||||||||||||||||||||||||||||
| 340 | $rel_pkg, | ||||||||||||||||||||||||||||||||||||||||||
| 341 | $dbic_colmap, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | accessor => ($reltype eq 'rel_one'? 'single' : 'multi'), | ||||||||||||||||||||||||||||||||||||||||||
| 344 | join_type => 'LEFT', | ||||||||||||||||||||||||||||||||||||||||||
| 345 | ($is_f_key? ( | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | ▶ | fk_columns => { map { do {(my $x= $_) =~ s/^self\.//; $x } => 1 } values %$dbic_colmap }, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | is_depends_on => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | is_foreign_key_constraint => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | undef_on_null_fk => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 350 | ) : ( | ||||||||||||||||||||||||||||||||||||||||||
| 351 | is_depends_on => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 352 | )), | ||||||||||||||||||||||||||||||||||||||||||
| 353 | cascade_copy => 0, cascade_delete => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 354 | %$opts | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 9 | require DBIx::Class::Core; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 9 | DBIx::Class::Core->can($reltype)->($pkg, $relname, $rel_pkg, $dbic_colmap, $opts); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | ▶ | sub ddl_cascade { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ddl_cascade: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 4 | my $mode= shift; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 4 | ▶ | $mode= 'CASCADE' if !defined $mode || $mode eq '1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $mode or $mode eq 1
MC/DC0%0/2
not defined $mode or $mode eq 1
not defined $mode
$mode eq 1
Truth table33%1/3
not(A) or B
A= not defined $modeB= $mode eq 1
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 4 | ▶ | $mode= 'RESTRICT' if $mode eq '0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | return | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 4 | on_update => $mode, | |||||||||||||||||||||||||||||||||||||||||
| 370 | on_delete => $mode; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | ▶ | sub dbic_cascade { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbic_cascade: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | ▶ | my $mode= defined $_[0]? $_[0] : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | return | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | cascade_copy => $mode, | |||||||||||||||||||||||||||||||||||||||||
| 378 | cascade_delete => $mode; | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | ▶ | sub view { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
view: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 2 | my ($name, $definition, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | ▶ | my $pkg= $CALLER || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | DBIx::Class::Core->can('table_class')->($pkg, 'DBIx::Class::ResultSource::View'); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | DBIx::Class::Core->can('table')->($pkg, $name); | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | my $rsi = $pkg->result_source_instance; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | $rsi->view_definition($definition); | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | ▶ | $rsi->deploy_depends_on($opts{depends}) if $opts{depends}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 2 | $rsi->is_virtual($opts{virtual}); | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | return $rsi | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 8 | our %_installed_sqlt_hook_functions; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 5 | ▶ | sub _get_sqlt_hook_method_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_sqlt_hook_method_array: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 5 | my $pkg= shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | ▶ | $_installed_sqlt_hook_functions{$pkg} ||= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$DBIx::Class::ResultDDL::_installed_sqlt_hook_functions{$pkg} ||= do {
no strict 'refs';
my $stash = %{$pkg . '::';};
croak("${pkg}::sqlt_deploy_hook already exists; DBIx::Class::ResultDDL won't overwrite it." . ' (but you can use Moo(se) or Class::Method::Modifiers to apply your own wrapper to this generated method)') if $stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"};
BEGIN {${^WARNING_BITS} = "\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
my @methods;
eval 'sub ' . $pkg . "::sqlt_deploy_hook {\n\t\t\tmy \$self= shift;\n\t\t\t\$self->maybe::next::method(\@_);\n\t\t\tfor (\@methods) {\n\t\t\t\tmy (\$m, \@args)= \@\$_;\n\t\t\t\t\$_[0]->\$m(\@args);\n\t\t\t}\n\t\t} 1" or die "failed to generate sqlt_deploy_hook: $@";
\@methods
}
MC/DC0%0/2
$DBIx::Class::ResultDDL::_installed_sqlt_hook_functions{$pkg} ||= do {
no strict 'refs';
my $stash = %{$pkg . '::';};
croak("${pkg}::sqlt_deploy_hook already exists; DBIx::Class::ResultDDL won't overwrite it." . ' (but you can use Moo(se) or Class::Method::Modifiers to apply your own wrapper to this generated method)') if $stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"};
BEGIN {${^WARNING_BITS} = "\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
my @methods;
eval 'sub ' . $pkg . "::sqlt_deploy_hook {\n\t\t\tmy \$self= shift;\n\t\t\t\$self->maybe::next::method(\@_);\n\t\t\tfor (\@methods) {\n\t\t\t\tmy (\$m, \@args)= \@\$_;\n\t\t\t\t\$_[0]->\$m(\@args);\n\t\t\t}\n\t\t} 1" or die "failed to generate sqlt_deploy_hook: $@";
\@methods
}
$DBIx::Class::ResultDDL::_installed_sqlt_hook_functions{$pkg}
do {
no strict 'refs';
my $stash = %{$pkg . '::';};
croak("${pkg}::sqlt_deploy_hook already exists; DBIx::Class::ResultDDL won't overwrite it." . ' (but you can use Moo(se) or Class::Method::Modifiers to apply your own wrapper to this generated method)') if $stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"};
BEGIN {${^WARNING_BITS} = "\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
my @methods;
eval 'sub ' . $pkg . "::sqlt_deploy_hook {\n\t\t\tmy \$self= shift;\n\t\t\t\$self->maybe::next::method(\@_);\n\t\t\tfor (\@methods) {\n\t\t\t\tmy (\$m, \@args)= \@\$_;\n\t\t\t\t\$_[0]->\$m(\@args);\n\t\t\t}\n\t\t} 1" or die "failed to generate sqlt_deploy_hook: $@";
\@methods
}
Truth table66%2/3
A ||= B
A= $DBIx::Class::ResultDDL::_installed_sqlt_hook_functions{$pkg}B= do {
no strict 'refs';
my $stash = %{$pkg . '::';};
croak("${pkg}::sqlt_deploy_hook already exists; DBIx::Class::ResultDDL won't overwrite it." . ' (but you can use Moo(se) or Class::Method::Modifiers to apply your own wrapper to this generated method)') if $stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"};
BEGIN {${^WARNING_BITS} = "\x51\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"}
my @methods;
eval 'sub ' . $pkg . "::sqlt_deploy_hook {\n\t\t\tmy \$self= shift;\n\t\t\t\$self->maybe::next::method(\@_);\n\t\t\tfor (\@methods) {\n\t\t\t\tmy (\$m, \@args)= \@\$_;\n\t\t\t\t\$_[0]->\$m(\@args);\n\t\t\t}\n\t\t} 1" or die "failed to generate sqlt_deploy_hook: $@";
\@methods
}
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | # $pkg->can("sqlt_deploy_hook") is insufficient, because it might be declared | ||||||||||||||||||||||||||||||||||||||||||
| 403 | # in a parent class, and that is not an error. It is only an error if it was | ||||||||||||||||||||||||||||||||||||||||||
| 404 | # already declared in this package. | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 2 | my $stash= %{$pkg.'::'}; | |||||||||||||||||||||||||||||||||||||||||
| 407 | croak "${pkg}::sqlt_deploy_hook already exists; DBIx::Class::ResultDDL won't overwrite it." | ||||||||||||||||||||||||||||||||||||||||||
| 408 | ." (but you can use Moo(se) or Class::Method::Modifiers to apply your own wrapper to this generated method)" | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | if $stash->{sqlt_deploy_hook} && $stash->{sqlt_deploy_hook}{CODE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"}
MC/DC0%0/2
$stash->{"sqlt_deploy_hook"} and $stash->{"sqlt_deploy_hook"}{"CODE"}
$stash->{"sqlt_deploy_hook"}
$stash->{"sqlt_deploy_hook"}{"CODE"}
Truth table33%1/3
A and B
A= $stash->{"sqlt_deploy_hook"}B= $stash->{"sqlt_deploy_hook"}{"CODE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | # Create the sub once, bound to this array. The array can then be extended without | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # needing to re-declare the sub. | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 8 | ▶ | no warnings 'closure'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | my @methods; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | eval 'sub '.$pkg.'::sqlt_deploy_hook { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqlt_deploy_hook: called CC=2 SCAR=7.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | my $self= shift; | ||||||||||||||||||||||||||||||||||||||||||
| 417 | $self->maybe::next::method(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 418 | for (@methods) { | ||||||||||||||||||||||||||||||||||||||||||
| 419 | my ($m, @args)= @$_; | ||||||||||||||||||||||||||||||||||||||||||
| 420 | $_[0]->$m(@args); | ||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | } 1' or die "failed to generate sqlt_deploy_hook: $@"; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | \@methods; | |||||||||||||||||||||||||||||||||||||||||
| 424 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | ▶ | sub sqlt_add_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqlt_add_index: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | ▶ | my $pkg= $CALLER || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my $methods= _get_sqlt_hook_method_array($pkg); | |||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | push @$methods, [ add_index => @_ ]; | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | ▶ | sub sqlt_add_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sqlt_add_constraint: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | ▶ | my $pkg= $CALLER || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | my $methods= _get_sqlt_hook_method_array($pkg); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | push @$methods, [ add_constraint => @_ ]; | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | ▶ | sub create_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_index: called CC=8 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 3 | ▶ | my $pkg= $CALLER || caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$DBIx::Class::ResultDDL::CALLER || caller
MC/DC0%0/2
$DBIx::Class::ResultDDL::CALLER || caller
$DBIx::Class::ResultDDL::CALLER
caller
Truth table33%1/3
A || B
A= $DBIx::Class::ResultDDL::CALLERB= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 3 | ▶ | my $name= ref $_[0]? undef : shift; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 3 | my $fields= shift; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 3 | ▶ | ref $fields eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | or croak((defined $name? 'Second':'First').' argument must be arrayref of index fields'); | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | my %options= @_; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | my $type= delete $options{type}; # this is an attribute of Index, not a member of %options | |||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | my $methods= _get_sqlt_hook_method_array($pkg); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | ▶ | push @$methods, [ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | add_index => | ||||||||||||||||||||||||||||||||||||||||||
| 449 | (defined $name? (name => $name) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 450 | fields => $fields, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | (keys %options? (options => \%options) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 452 | (defined $type? (type => $type) : ()) | ||||||||||||||||||||||||||||||||||||||||||
| 453 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 8 | ▶ | BEGIN { *idx= *create_index; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 153 | ▶ | sub expand_col_options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_col_options: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 153 | my $pkg= shift; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 153 | my $opts= { is_nullable => 0 }; | |||||||||||||||||||||||||||||||||||||||||
| 462 | # Apply options to the hash in order, so that they get overwritten as expected | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 153 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 338 | my ($k, $v)= (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 465 | 338 | ▶ | $opts->{$k}= $v, next | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | unless index($k, '.') >= 0; | ||||||||||||||||||||||||||||||||||||||||||
| 467 | # We support "foo.bar => $v" syntax which we convert to "foo => { bar => $v }" | ||||||||||||||||||||||||||||||||||||||||||
| 468 | # because "foo => { bar => 1 }, foo => { baz => 2 }" would overwrite eachother. | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 9 | my @path= split /\./, $k; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 9 | $k= pop @path; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 9 | my $dest= $opts; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 9 | ▶ | $dest= ($dest->{$_} ||= {}) for @path; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$dest->{$_} ||= {}
MC/DC100%1/1
$dest->{$_} ||= {}
$dest->{$_}
Truth table100%2/2
A
A= $dest->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 9 | $dest->{$k}= $v; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | $opts->{retrieve_on_insert}= 1 | ||||||||||||||||||||||||||||||||||||||||||
| 476 | if $opts->{default_value} and !defined $opts->{retrieve_on_insert} | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 153 | ▶ | and _settings_for_package($pkg)->{retrieve_defaults}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$opts->{"default_value"} and not defined $opts->{"retrieve_on_insert"} and _settings_for_package($pkg)->{"retrieve_defaults"}
$opts->{"default_value"} and not defined $opts->{"retrieve_on_insert"}
MC/DC66%2/3
$opts->{"default_value"} and not defined $opts->{"retrieve_on_insert"} and _settings_for_package($pkg)->{"retrieve_defaults"}
$opts->{"default_value"}
not defined $opts->{"retrieve_on_insert"}
_settings_for_package($pkg)->{"retrieve_defaults"}
Truth table75%3/4
A and not(B) and C
A= $opts->{"default_value"}B= not defined $opts->{"retrieve_on_insert"}C= _settings_for_package($pkg)->{"retrieve_defaults"}
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 153 | return $opts; | |||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 16 | ▶ | sub expand_relationship_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_relationship_params: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 16 | my ($pkg, $reltype, $relname, $maybe_colmap)= splice(@_, 0, 4); | |||||||||||||||||||||||||||||||||||||||||
| 483 | 16 | ▶ | my ($rel_pkg, $dbic_colmap, %opts)= ref $maybe_colmap eq 'HASH'? _translate_colmap($maybe_colmap, $pkg) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not ref $maybe_colmap and $maybe_colmap =~ /JOIN /
MC/DC50%1/2
not ref $maybe_colmap and $maybe_colmap =~ /JOIN /
not ref $maybe_colmap
$maybe_colmap =~ /JOIN /
Truth table66%2/3
not(A) and B
A= not ref $maybe_colmapB= $maybe_colmap =~ /JOIN /
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | : !ref $maybe_colmap && $maybe_colmap =~ /JOIN /? _translate_join_sql($maybe_colmap, $pkg) | ||||||||||||||||||||||||||||||||||||||||||
| 485 | : !ref $maybe_colmap? ( _interpret_pkg_name($maybe_colmap, $pkg), shift ) | ||||||||||||||||||||||||||||||||||||||||||
| 486 | : croak "Unexpected arguments"; | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 16 | %opts= (%opts, @_); | |||||||||||||||||||||||||||||||||||||||||
| 488 | 16 | return $pkg, $reltype, $relname, $rel_pkg, $dbic_colmap, \%opts; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 16 | ▶ | sub _interpret_pkg_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_interpret_pkg_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 16 | my ($rel_class, $current_pkg)= @_; | |||||||||||||||||||||||||||||||||||||||||
| 493 | # Related class may be relative to same namespace as current | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 16 | ▶ | return $rel_class if index($rel_class, '::') >= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 14 | my ($parent_namespace)= ($current_pkg =~ /(.*)::[^:]+$/); | |||||||||||||||||||||||||||||||||||||||||
| 496 | 14 | return $parent_namespace.'::'.$rel_class; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | # DBIC is normally { foreign.col => self.col } but I don't think that's very intuitive, | ||||||||||||||||||||||||||||||||||||||||||
| 500 | # so allow an alternate notation of { self_col => CLASS.col } and automatically determine | ||||||||||||||||||||||||||||||||||||||||||
| 501 | # which the user is using. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 12 | ▶ | sub _translate_colmap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_translate_colmap: called CC=26 SCAR=41.2
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 12 | my ($colmap, $self_pkg)= @_; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 12 | my ($rel_class, $direction, %result, $inconsistent)= ('',0); | |||||||||||||||||||||||||||||||||||||||||
| 505 | # First pass, find the values for $rel_class and $reverse | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 12 | for (keys %$colmap) { | |||||||||||||||||||||||||||||||||||||||||
| 507 | 12 | my ($key, $val)= ($_, $colmap->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 12 | ▶ | if ($key =~ /([^.]+)\.(.*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | ▶ | if ($1 eq 'self') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | $direction ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$direction ||= 1
MC/DC0%0/1
$direction ||= 1
$direction
Truth table0%0/2
A
A= $direction
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | ++$inconsistent if $direction < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 513 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 1 | ▶ | $direction ||= -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$direction ||= -1
MC/DC0%0/1
$direction ||= -1
$direction
Truth table50%1/2
A
A= $direction
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | ▶ | ++$inconsistent if $direction > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | ▶ | if ($1 ne 'foreign') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | ▶ | $rel_class ||= $1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$rel_class ||= $1
MC/DC0%0/2
$rel_class ||= $1
$rel_class
$1
Truth table33%1/3
A ||= B
A= $rel_classB= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 1 | ▶ | ++$inconsistent if $rel_class ne $1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 12 | ▶ | if ($val =~ /([^.]+)\.(.*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 11 | ▶ | if ($1 eq 'self') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | $direction ||= -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$direction ||= -1
MC/DC0%0/1
$direction ||= -1
$direction
Truth table0%0/2
A
A= $direction
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | ++$inconsistent if $direction > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 11 | ▶ | $direction ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$direction ||= 1
MC/DC0%0/1
$direction ||= 1
$direction
Truth table50%1/2
A
A= $direction
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 11 | ▶ | ++$inconsistent if $direction < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 11 | ▶ | if ($1 ne 'foreign') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 11 | ▶ | $rel_class ||= $1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$rel_class ||= $1
MC/DC0%0/2
$rel_class ||= $1
$rel_class
$1
Truth table33%1/3
A ||= B
A= $rel_classB= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 11 | ▶ | ++$inconsistent if $rel_class ne $1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | 12 | ▶ | croak "Inconsistent {self=>foreign} notation found in relation mapping" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | if $inconsistent; | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 12 | ▶ | croak "Must reference foreign Result class name in one of the keys or values of relation mapping" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$rel_class and $direction
MC/DC0%0/2
$rel_class and $direction
$rel_class
$direction
Truth table33%1/3
A and B
A= $rel_classB= $direction
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | unless $rel_class && $direction; | ||||||||||||||||||||||||||||||||||||||||||
| 541 | # Related class may be relative to same namespace as current | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 12 | $rel_class= _interpret_pkg_name($rel_class, $self_pkg); | |||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # Second pass, rename the keys & values to DBIC canonical notation | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 12 | for (keys %$colmap) { | |||||||||||||||||||||||||||||||||||||||||
| 546 | 12 | my ($key, $val)= ($_, $colmap->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 547 | 12 | $key =~ s/.*\.//; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 12 | $val =~ s/.*\.//; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 12 | ▶ | $result{ $direction > 0? "foreign.$val" : "foreign.$key" }= $direction > 0? "self.$key" : "self.$val"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 12 | return $rel_class, \%result; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | sub _translate_join_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_translate_join_sql: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 2 | my ($sql, $self_pkg)= @_; | |||||||||||||||||||||||||||||||||||||||||
| 556 | 2 | ▶ | my ($join_type, $rsrc, $alias, $on, $tpl) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | = ($sql =~ /^\s*(LEFT\s*|INNER\s*)?JOIN\s+(\S+)\s+(\w+)\s+(ON\s+)?(.*)/si) | ||||||||||||||||||||||||||||||||||||||||||
| 558 | or Carp::croak("Can't pase SQL, make sure it starts with (LEFT)? JOIN \$class (\$alias)? ON ...\n$sql"); | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | my $rel_class= _interpret_pkg_name($rsrc, $self_pkg); | |||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | ▶ | my $replace= $alias =~ /^ON\s*$/i? $rsrc : $alias; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | $tpl =~ s/(["\$\@\\])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | $tpl =~ s/\b\Q$replace\E[.]/\$_[0]{foreign_alias}./g; | |||||||||||||||||||||||||||||||||||||||||
| 563 | 2 | $tpl =~ s/\bself[.]/\$_[0]{self_alias}./g; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 2 | ▶ | my $tpl_fn= eval 'sub { \"'.$tpl.'" }' or die "$@\n in generated expression \"$tpl\""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | ▶ | return $rel_class, $tpl_fn, ($join_type? (join_type => $join_type) : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | __END__ | ||||||||||||||||||||||||||||||||||||||||||