« blib/lib/DBIx/Class/Schema/Loader/DBI/ODBC/ACCESS.pm
↑ Summary
blib/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm »
| 1 | package DBIx::Class::Schema::Loader::DBI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 49 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 49 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 49 | ▶ | use base qw/DBIx::Class::Schema::Loader::Base/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 49 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 49 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 49 | ▶ | use List::Util 'any'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 49 | ▶ | use Carp::Clan qw/^DBIx::Class/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 49 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 49 | ▶ | use DBIx::Class::Schema::Loader::Table (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 49 | our $VERSION = '0.07053'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 49 | __PACKAGE__->mk_group_accessors('simple', qw/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | _disable_pk_detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | _disable_uniq_detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | _disable_fk_detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | _passwords | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | quote_char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | name_sep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | /); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | DBIx::Class::Schema::Loader::DBI - DBIx::Class::Schema::Loader DBI Implementation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | See L<DBIx::Class::Schema::Loader::Base> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | This is the base class for L<DBIx::Class::Schema::Loader::Base> classes for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | DBI-based storage backends, and implements the common functionality between them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | See L<DBIx::Class::Schema::Loader::Base> for the available options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | Overlays L<DBIx::Class::Schema::Loader::Base/new> to do some DBI-specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 140 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 140 | my $self = shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # rebless to vendor-specific class if it exists and loads and we're not in a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # custom class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 140 | ▶ | if (not $self->loader_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 140 | my $driver = $self->dbh->{Driver}->{Name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 140 | my $subclass = 'DBIx::Class::Schema::Loader::DBI::' . $driver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 140 | ▶ | if ((not $self->isa($subclass)) && $self->load_optional_class($subclass)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->isa($subclass) and $self->load_optional_class($subclass)
MC/DC0%0/2
not $self->isa($subclass) and $self->load_optional_class($subclass)
not $self->isa($subclass)
$self->load_optional_class($subclass)
Truth table33%1/3
not(A) and B
A= not $self->isa($subclass)B= $self->load_optional_class($subclass)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 140 | bless $self, $subclass; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 140 | $self->_rebless; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 140 | ▶ | Class::C3::reinitialize() if $] < 5.009005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # Set up the default quoting character and name separators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 140 | $self->quote_char($self->_build_quote_char); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 140 | $self->name_sep($self->_build_name_sep); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 140 | $self->_setup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 140 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 140 | ▶ | sub _build_quote_char { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_quote_char: called CC=4 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 140 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 140 | ▶ | my $quote_char = $self->dbh->get_info(29) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$self->dbh->get_info(29) || $self->schema->storage->sql_maker->quote_char || '"'
$self->dbh->get_info(29) or $self->schema->storage->sql_maker->quote_char
MC/DC0%0/2
$self->dbh->get_info(29) || $self->schema->storage->sql_maker->quote_char || '"'
$self->dbh->get_info(29)
$self->schema->storage->sql_maker->quote_char
Truth table33%1/3
A or B
A= $self->dbh->get_info(29)B= $self->schema->storage->sql_maker->quote_char
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | || $self->schema->storage->sql_maker->quote_char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | || q{"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # For our usage as regex matches, concatenating multiple quote_char | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # values works fine (e.g. s/[\Q<>\E]// if quote_char was [ '<', '>' ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 140 | ▶ | if (ref $quote_char eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $quote_char = join '', @$quote_char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 140 | return $quote_char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 140 | ▶ | sub _build_name_sep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_name_sep: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 140 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 140 | ▶ | return $self->dbh->get_info(41) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$self->dbh->get_info(41) || $self->schema->storage->sql_maker->name_sep || '.'
$self->dbh->get_info(41) or $self->schema->storage->sql_maker->name_sep
MC/DC0%0/2
$self->dbh->get_info(41) || $self->schema->storage->sql_maker->name_sep || '.'
$self->dbh->get_info(41)
$self->schema->storage->sql_maker->name_sep
Truth table33%1/3
A or B
A= $self->dbh->get_info(41)B= $self->schema->storage->sql_maker->name_sep
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | || $self->schema->storage->sql_maker->name_sep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | || '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # Override this in vendor modules to do things at the end of ->new() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 142 | ▶ | sub _setup { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # Override this in vendor module to load a subclass if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 140 | ▶ | sub _rebless { } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rebless: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub _system_schemas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system_schemas: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return ('information_schema'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub _system_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system_tables: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub _dbh_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_tables: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return $self->dbh->tables(undef, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # default to be overridden in subclasses if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub _supports_db_schema { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_supports_db_schema: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # Returns an array of table objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub _tables_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tables_list: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my @tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $qt = qr/[\Q$self->{quote_char}\E"'`\[\]]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $nqt = qr/[^\Q$self->{quote_char}\E"'`\[\]]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $ns = qr/[\Q$self->{name_sep}\E]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $nns = qr/[^\Q$self->{name_sep}\E]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | foreach my $schema (@{ $self->db_schema || [undef] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->db_schema || [undef]
MC/DC0%0/1
$self->db_schema || [undef]
$self->db_schema
Truth table0%0/2
A
A= $self->db_schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my @raw_table_names = $self->_dbh_tables($schema); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | TABLE: foreach my $raw_table_name (@raw_table_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $quoted = $raw_table_name =~ /^$qt/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # These regexes are not entirely correct, but hopefully they will work | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # in most cases. RT reports welcome. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my ($schema_name, $table_name1, $table_name2) = $quoted ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | $raw_table_name =~ /^(?:${qt}(${nqt}+?)${qt}${ns})?(?:${qt}(.+?)${qt}|(${nns}+))\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | $raw_table_name =~ /^(?:(${nns}+?)${ns})?(?:${qt}(.+?)${qt}|(${nns}+))\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my $table_name = $table_name1 || $table_name2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$table_name1 || $table_name2
MC/DC0%0/2
$table_name1 || $table_name2
$table_name1
$table_name2
Truth table0%0/3
A || B
A= $table_name1B= $table_name2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | foreach my $system_schema ($self->_system_schemas) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ($schema_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $matches = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if (ref $system_schema) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $matches = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$schema_name =~ /$system_schema/ and not $schema =~ /$system_schema/
MC/DC0%0/2
$schema_name =~ /$system_schema/ and not $schema =~ /$system_schema/
$schema_name =~ /$system_schema/
not $schema =~ /$system_schema/
Truth table0%0/3
A and not(B)
A= $schema_name =~ /$system_schema/B= not $schema =~ /$system_schema/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | if $schema_name =~ $system_schema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | && $schema !~ $system_schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $matches = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$schema_name eq $system_schema and $schema ne $system_schema
MC/DC0%0/2
$schema_name eq $system_schema and $schema ne $system_schema
$schema_name eq $system_schema
$schema ne $system_schema
Truth table0%0/3
A and B
A= $schema_name eq $system_schemaB= $schema ne $system_schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | if $schema_name eq $system_schema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | && $schema ne $system_schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | next TABLE if $matches; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | foreach my $system_table ($self->_system_tables) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $matches = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (ref $system_table) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $matches = 1 if $table_name =~ $system_table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | $matches = 1 if $table_name eq $system_table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | next TABLE if $matches; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $schema_name ||= $schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$schema_name ||= $schema
MC/DC0%0/2
$schema_name ||= $schema
$schema_name
$schema
Truth table0%0/3
A ||= B
A= $schema_nameB= $schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | my $table = DBIx::Class::Schema::Loader::Table->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | loader => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | name => $table_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | schema => $schema_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ($self->_supports_db_schema ? () : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ignore_schema => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | push @tables, $table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $self->_filter_tables(\@tables); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | ▶ | sub _recurse_constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_recurse_constraint: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 16 | my ($constraint, @parts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 16 | my $name = shift @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # If there are any parts left, the constraint must be an arrayref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 16 | ▶ | croak "depth of constraint/exclude array does not match length of moniker_parts" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | unless !!@parts == !!(ref $constraint eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # if ths is the last part, use the constraint directly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 16 | ▶ | return $name =~ $constraint unless @parts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # recurse into the first matching subconstraint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | foreach (@{$constraint}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 8 | my ($re, $sub) = @{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 8 | ▶ | return _recurse_constraint($sub, @parts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | if $name =~ $re; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 290 | ▶ | sub _check_constraint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_constraint: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 290 | my ($include, $constraint, @tables) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 290 | ▶ | return @tables unless defined $constraint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11 | ▶ | return grep { !$include xor _recurse_constraint($constraint, @{$_}) } @tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
!$include ^^ _recurse_constraint($constraint, @{$_;})
MC/DC100%2/2
!$include ^^ _recurse_constraint($constraint, @{$_;})
!$include
_recurse_constraint($constraint, @{$_;})
Truth table75%3/4
not(A) ^^ B
A= !$includeB= _recurse_constraint($constraint, @{$_;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | if ref $constraint eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | ▶ | return grep { !$include xor /$constraint/ } @tables; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
!$include ^^ /$constraint/
MC/DC0%0/2
!$include ^^ /$constraint/
!$include
/$constraint/
Truth table25%1/4
not(A) ^^ B
A= !$includeB= /$constraint/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # apply constraint/exclude and ignore bad tables and views | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 145 | ▶ | sub _filter_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_tables: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 145 | my ($self, $tables) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 145 | my @tables = @$tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 145 | my @filtered_tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 145 | @tables = _check_constraint(1, $self->constraint, @tables); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 145 | @tables = _check_constraint(0, $self->exclude, @tables); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 145 | TABLE: for my $table (@tables) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 833 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 833 | local $^W = 0; # for ADO | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 833 | my $sth = $self->_sth_for($table, undef, \'1 = 0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 833 | $sth->execute; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 833 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | warn "Bad table or view '$table', ignoring: $_\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 833 | ▶ | } or next TABLE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 833 | push @filtered_tables, $table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 145 | return @filtered_tables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =head2 load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | We override L<DBIx::Class::Schema::Loader::Base/load> here to hook in our localized settings for C<$dbh> error handling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 140 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 140 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 140 | local $self->dbh->{RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 140 | local $self->dbh->{PrintError} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 140 | $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2487 | ▶ | sub _sth_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sth_for: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2487 | my ($self, $table, $fields, $where) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2487 | ▶ | my $sth = $self->dbh->prepare($self->schema->storage->sql_maker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fields || \'*'
MC/DC0%0/1
$fields || \'*'
$fields
Truth table50%1/2
A
A= $fields
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ->select(\$table->sql_name, $fields || \'*', $where)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2487 | return $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # Returns an arrayref of column names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 827 | ▶ | sub _table_columns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_columns: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 827 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 827 | my $sth = $self->_sth_for($table, undef, \'1 = 0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 827 | $sth->execute; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 827 | my $retval = [ map $self->_lc($_), @{$sth->{NAME}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 827 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 827 | return $retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # Returns arrayref of pk col names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 827 | ▶ | sub _table_pk_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_pk_info: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 827 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 827 | ▶ | return [] if $self->_disable_pk_detection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 827 | ▶ | my @primary = try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 827 | $self->dbh->primary_key('', $table->schema, $table->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | warn "Cannot find primary keys for this driver: $_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self->_disable_pk_detection(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 827 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 827 | ▶ | return [] if not @primary; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 806 | @primary = map { $self->_lc($_) } @primary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 806 | s/[\Q$self->{quote_char}\E]//g for @primary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 806 | return \@primary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # Override this for vendor-specific uniq info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub _table_uniq_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_uniq_info: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return [] if $self->_disable_uniq_detection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if (not $self->dbh->can('statistics_info')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | warn "No UNIQUE constraint information can be gathered for this driver"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->_disable_uniq_detection(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my %indices; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $sth = $self->dbh->statistics_info(undef, $table->schema, $table->name, 1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | while(my $row = $sth->fetchrow_hashref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # skip table-level stats, conditional indexes, and any index missing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # critical fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | next if $row->{TYPE} eq 'table' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | || defined $row->{FILTER_CONDITION} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | || !$row->{INDEX_NAME} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | || !defined $row->{ORDINAL_POSITION}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$row->{"TYPE"} eq "table" or defined $row->{"FILTER_CONDITION"} or not $row->{"INDEX_NAME"} or not defined $row->{"ORDINAL_POSITION"}
$row->{"TYPE"} eq "table" or defined $row->{"FILTER_CONDITION"} or not $row->{"INDEX_NAME"}
$row->{"TYPE"} eq "table" or defined $row->{"FILTER_CONDITION"}
MC/DC0%0/4
$row->{"TYPE"} eq "table" or defined $row->{"FILTER_CONDITION"} or not $row->{"INDEX_NAME"} or not defined $row->{"ORDINAL_POSITION"}
$row->{"TYPE"} eq "table"
defined $row->{"FILTER_CONDITION"}
not $row->{"INDEX_NAME"}
not defined $row->{"ORDINAL_POSITION"}
Truth table0%0/5
A or B or not(C) or not(D)
A= $row->{"TYPE"} eq "table"B= defined $row->{"FILTER_CONDITION"}C= not $row->{"INDEX_NAME"}D= not defined $row->{"ORDINAL_POSITION"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $indices{$row->{INDEX_NAME}}[$row->{ORDINAL_POSITION}] = $self->_lc($row->{COLUMN_NAME} || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$row->{'COLUMN_NAME'} || ''
MC/DC0%0/1
$row->{'COLUMN_NAME'} || ''
$row->{'COLUMN_NAME'}
Truth table0%0/2
A
A= $row->{'COLUMN_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my @retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | foreach my $index_name (sort keys %indices) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my (undef, @cols) = @{$indices{$index_name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # skip indexes with missing column names (e.g. expression indexes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | next unless @cols == grep $_, @cols; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | push(@retval, [ $index_name => \@cols ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return \@retval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1632 | ▶ | sub _table_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_comment: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 1632 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1632 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1632 | my $comments_table = $table->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1632 | $comments_table->name($self->table_comments_table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | my ($comment) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | (exists $self->_tables->{$comments_table->sql_name} || undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1632 | ▶ | && try { $dbh->selectrow_array(<<"EOF") }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition80%4/5
(exists $self->_tables->{$comments_table->sql_name} || undef) && &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\n");
}
)
exists $self->_tables->{$comments_table->sql_name} or undef
MC/DC50%1/2
(exists $self->_tables->{$comments_table->sql_name} || undef) && &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\n");
}
)
exists $self->_tables->{$comments_table->sql_name}
&try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\n");
}
)
Truth table66%2/3
A && B
A= exists $self->_tables->{$comments_table->sql_name}B= &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\n");
}
)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | SELECT comment_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 16 | FROM @{[ $comments_table->sql_name ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 16 | WHERE table_name = @{[ $dbh->quote($table->name) ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # Failback: try the REMARKS column on table_info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1632 | ▶ | if (!$comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1628 | my $info = $self->_dbh_table_info( $dbh, $table ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1628 | ▶ | $comment = $info->{REMARKS} if $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1632 | return $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2300 | ▶ | sub _column_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_column_comment: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2300 | my ($self, $table, $column_number, $column_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2300 | my $dbh = $self->dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2300 | my $comments_table = $table->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2300 | $comments_table->name($self->column_comments_table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | my ($comment) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | (exists $self->_tables->{$comments_table->sql_name} || undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2300 | ▶ | && try { $dbh->selectrow_array(<<"EOF") }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition80%4/5
(exists $self->_tables->{$comments_table->sql_name} || undef) && &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\nAND column_name = @{[$dbh->quote($column_name)];}\n");
}
)
exists $self->_tables->{$comments_table->sql_name} or undef
MC/DC50%1/2
(exists $self->_tables->{$comments_table->sql_name} || undef) && &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\nAND column_name = @{[$dbh->quote($column_name)];}\n");
}
)
exists $self->_tables->{$comments_table->sql_name}
&try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\nAND column_name = @{[$dbh->quote($column_name)];}\n");
}
)
Truth table66%2/3
A && B
A= exists $self->_tables->{$comments_table->sql_name}B= &try(sub {
$dbh->selectrow_array("SELECT comment_text\nFROM @{[$comments_table->sql_name];}\nWHERE table_name = @{[$dbh->quote($table->name)];}\nAND column_name = @{[$dbh->quote($column_name)];}\n");
}
)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | SELECT comment_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 19 | FROM @{[ $comments_table->sql_name ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 19 | WHERE table_name = @{[ $dbh->quote($table->name) ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 19 | AND column_name = @{[ $dbh->quote($column_name) ]} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Failback: try the REMARKS column on column_info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 2300 | ▶ | if (!$comment && $dbh->can('column_info')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $comment and $dbh->can("column_info")
MC/DC50%1/2
not $comment and $dbh->can("column_info")
not $comment
$dbh->can("column_info")
Truth table66%2/3
not(A) and B
A= not $commentB= $dbh->can("column_info")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2298 | ▶ | if (my $sth = try { $self->_dbh_column_info( $dbh, undef, $table->schema, $table->name, $column_name ) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2298 | my $info = $sth->fetchrow_hashref(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 2298 | $comment = $info->{REMARKS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 2300 | return $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # Find relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub _table_fk_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_fk_info: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | return [] if $self->_disable_fk_detection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | my $sth = try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $self->dbh->foreign_key_info( '', '', '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$table->schema || ''
MC/DC0%0/1
$table->schema || ''
$table->schema
Truth table0%0/2
A
A= $table->schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | '', ($table->schema || ''), $table->name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | warn "Cannot introspect relationships for this driver: $_"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $self->_disable_fk_detection(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return [] if !$sth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my %rels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my @rules = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 'CASCADE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 'RESTRICT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 'SET NULL', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 'NO ACTION', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 'SET DEFAULT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $i = 1; # for unnamed rels, which hopefully have only 1 column ... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | REL: while(my $raw_rel = $sth->fetchrow_arrayref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $uk_scm = $raw_rel->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $uk_tbl = $raw_rel->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $uk_col = $self->_lc($raw_rel->[3]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $fk_scm = $raw_rel->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $fk_col = $self->_lc($raw_rel->[7]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $key_seq = $raw_rel->[8] - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | my $relid = ($raw_rel->[11] || ( "__dcsld__" . $i++ )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$raw_rel->[11] || '__dcsld__' . $i++
MC/DC0%0/1
$raw_rel->[11] || '__dcsld__' . $i++
$raw_rel->[11]
Truth table0%0/2
A
A= $raw_rel->[11]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $update_rule = $raw_rel->[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $delete_rule = $raw_rel->[10]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | $update_rule = $rules[$update_rule] if defined $update_rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $delete_rule = $rules[$delete_rule] if defined $delete_rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $is_deferrable = $raw_rel->[13]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | ($is_deferrable = $is_deferrable == 7 ? 0 : 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | if defined $is_deferrable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | foreach my $var ($uk_scm, $uk_tbl, $uk_col, $fk_scm, $fk_col, $relid) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $var =~ s/[\Q$self->{quote_char}\E]//g if defined $var; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if ($self->db_schema && $self->db_schema->[0] ne '%' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->db_schema and $self->db_schema->[0] ne "%" and not &any(sub {
$_ eq $uk_scm;
}
, @{$self->db_schema;})
$self->db_schema and $self->db_schema->[0] ne "%"
MC/DC0%0/3
$self->db_schema and $self->db_schema->[0] ne "%" and not &any(sub {
$_ eq $uk_scm;
}
, @{$self->db_schema;})
$self->db_schema
$self->db_schema->[0] ne "%"
not &any(sub {
$_ eq $uk_scm;
}
, @{$self->db_schema;})
Truth table0%0/4
A and B and not(C)
A= $self->db_schemaB= $self->db_schema->[0] ne "%"C= not &any(sub {
$_ eq $uk_scm;
}
, @{$self->db_schema;})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | && (not any { $_ eq $uk_scm } @{ $self->db_schema })) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | next REL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | $rels{$relid}{tbl} ||= DBIx::Class::Schema::Loader::Table->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rels{$relid}{"tbl"} ||= "DBIx::Class::Schema::Loader::Table"->new("loader", $self, "name", $uk_tbl, "schema", $uk_scm, $self->_supports_db_schema ? () : ("ignore_schema", 1))
MC/DC0%0/2
$rels{$relid}{"tbl"} ||= "DBIx::Class::Schema::Loader::Table"->new("loader", $self, "name", $uk_tbl, "schema", $uk_scm, $self->_supports_db_schema ? () : ("ignore_schema", 1))
$rels{$relid}{"tbl"}
"DBIx::Class::Schema::Loader::Table"->new("loader", $self, "name", $uk_tbl, "schema", $uk_scm, $self->_supports_db_schema ? () : ("ignore_schema", 1))
Truth table0%0/3
A ||= B
A= $rels{$relid}{"tbl"}B= "DBIx::Class::Schema::Loader::Table"->new("loader", $self, "name", $uk_tbl, "schema", $uk_scm, $self->_supports_db_schema ? () : ("ignore_schema", 1))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | loader => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | name => $uk_tbl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | schema => $uk_scm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ($self->_supports_db_schema ? () : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ignore_schema => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | )), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $rels{$relid}{attrs}{on_delete} = $delete_rule if $delete_rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | $rels{$relid}{attrs}{on_update} = $update_rule if $update_rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | $rels{$relid}{attrs}{is_deferrable} = $is_deferrable if defined $is_deferrable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # Add this data IN ORDER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $rels{$relid}{rcols}[$key_seq] = $uk_col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $rels{$relid}{lcols}[$key_seq] = $fk_col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my @rels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | foreach my $relid (keys %rels) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | push(@rels, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | remote_columns => [ grep defined, @{ $rels{$relid}{rcols} } ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | local_columns => [ grep defined, @{ $rels{$relid}{lcols} } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | remote_table => $rels{$relid}->{tbl}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | (exists $rels{$relid}{attrs} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | (attrs => $rels{$relid}{attrs}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | _constraint_name => $relid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | return \@rels; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # ported in from DBIx::Class::Storage::DBI: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 827 | ▶ | sub _columns_info_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_columns_info_for: called CC=29 SCAR=43.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 827 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 827 | my $dbh = $self->schema->storage->dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 827 | my %result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | my %raw_result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 827 | ▶ | if (my $sth = try { $self->_dbh_column_info($dbh, undef, $table->schema, $table->name, '%' ) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | COL_INFO: while (my $info = try { $sth->fetchrow_hashref } catch { +{} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2310 | ▶ | next COL_INFO unless %$info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 2310 | my $column_info = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 2310 | $column_info->{data_type} = lc $info->{TYPE_NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 2310 | my $size = $info->{COLUMN_SIZE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2310 | ▶ | if (defined $size && defined $info->{DECIMAL_DIGITS}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $size and defined $info->{"DECIMAL_DIGITS"}
MC/DC100%2/2
defined $size and defined $info->{"DECIMAL_DIGITS"}
defined $size
defined $info->{"DECIMAL_DIGITS"}
Truth table100%3/3
A and B
A= defined $sizeB= defined $info->{"DECIMAL_DIGITS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 21 | $column_info->{size} = [$size, $info->{DECIMAL_DIGITS}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | elsif (defined $size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 262 | $column_info->{size} = $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2310 | ▶ | $column_info->{is_nullable} = $info->{NULLABLE} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 2310 | ▶ | $column_info->{default_value} = $info->{COLUMN_DEF} if defined $info->{COLUMN_DEF}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2310 | my $col_name = $info->{COLUMN_NAME}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2310 | $col_name =~ s/^\"(.*)\"$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2310 | ▶ | my $extra_info = $self->_extra_column_info( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_extra_column_info($table, $col_name, $column_info, $info) || {}
MC/DC0%0/1
$self->_extra_column_info($table, $col_name, $column_info, $info) || {}
$self->_extra_column_info($table, $col_name, $column_info, $info)
Truth table50%1/2
A
A= $self->_extra_column_info($table, $col_name, $column_info, $info)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | $table, $col_name, $column_info, $info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2310 | $column_info = { %$column_info, %$extra_info }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 2310 | $raw_result{$col_name} = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 2310 | $result{$col_name} = $column_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 827 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 827 | my $sth = $self->_sth_for($table, undef, \'1 = 0'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 827 | $sth->execute; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 827 | my @columns = @{ $sth->{NAME} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 827 | COL: for my $i (0 .. $#columns) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2310 | ▶ | next COL if %{ $result{ $columns[$i] }||{} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$result{$columns[$i]} || {}
MC/DC0%0/1
$result{$columns[$i]} || {}
$result{$columns[$i]}
Truth table50%1/2
A
A= $result{$columns[$i]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $column_info = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $column_info->{data_type} = lc $sth->{TYPE}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $size = $sth->{PRECISION}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | if (defined $size && defined $sth->{SCALE}[$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $size and defined $sth->{"SCALE"}[$i]
MC/DC0%0/2
defined $size and defined $sth->{"SCALE"}[$i]
defined $size
defined $sth->{"SCALE"}[$i]
Truth table0%0/3
A and B
A= defined $sizeB= defined $sth->{"SCALE"}[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $column_info->{size} = [$size, $sth->{SCALE}[$i]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | elsif (defined $size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $column_info->{size} = $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | $column_info->{is_nullable} = $sth->{NULLABLE}[$i] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | if ($column_info->{data_type} =~ m/^(.*?)\((.*?)\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $column_info->{data_type} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $column_info->{size} = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | my $extra_info = $self->_extra_column_info($table, $columns[$i], $column_info, $sth) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_extra_column_info($table, $columns[$i], $column_info, $sth) || {}
MC/DC0%0/1
$self->_extra_column_info($table, $columns[$i], $column_info, $sth) || {}
$self->_extra_column_info($table, $columns[$i], $column_info, $sth)
Truth table0%0/2
A
A= $self->_extra_column_info($table, $columns[$i], $column_info, $sth)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $column_info = { %$column_info, %$extra_info }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $result{ $columns[$i] } = $column_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 827 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 827 | foreach my $col (keys %result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 2310 | my $colinfo = $result{$col}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 2310 | my $type_num = $colinfo->{data_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 2310 | my $type_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 2310 | ▶ | if (defined $type_num && $type_num =~ /^-?\d+\z/ && $dbh->can('type_info')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $type_num and $type_num =~ /^-?\d+\z/ and $dbh->can("type_info")
defined $type_num and $type_num =~ /^-?\d+\z/
MC/DC0%0/3
defined $type_num and $type_num =~ /^-?\d+\z/ and $dbh->can("type_info")
defined $type_num
$type_num =~ /^-?\d+\z/
$dbh->can("type_info")
Truth table25%1/4
A and B and C
A= defined $type_numB= $type_num =~ /^-?\d+\z/C= $dbh->can("type_info")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $type_name = $self->_dbh_type_info_type_name($type_num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | $colinfo->{data_type} = lc $type_name if $type_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # check for instances of the same column name with different case in preserve_case=0 mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 827 | ▶ | if (not $self->preserve_case) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 355 | my %lc_colnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 355 | foreach my $col (keys %result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 914 | push @{ $lc_colnames{lc $col} }, $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 355 | ▶ | if (keys %lc_colnames != keys %result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my @offending_colnames = map @$_, grep @$_ > 1, values %lc_colnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $offending_colnames = join ", ", map "'$_'", @offending_colnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | croak "columns $offending_colnames in table @{[ $table->sql_name ]} collide in preserve_case=0 mode. preserve_case=1 mode required"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # apply lowercasing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 355 | my %lc_result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 355 | ▶ | while (my ($col, $info) = each %result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 914 | $lc_result{ $self->_lc($col) } = $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 355 | %result = %lc_result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 827 | ▶ | return wantarray ? (\%result, \%raw_result) : \%result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # Need to override this for the buggy Firebird ODBC driver. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | sub _dbh_type_info_type_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_type_info_type_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my ($self, $type_num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # We wrap it in a try block for MSSQL+DBD::Sybase, which can have issues. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # TODO investigate further | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | my $type_info = try { $self->dbh->type_info($type_num) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | return $type_info ? $type_info->{TYPE_NAME} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # do not use this, override _columns_info_for instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 2310 | ▶ | sub _extra_column_info {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extra_column_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # override to mask warnings if needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2455 | ▶ | sub _dbh_table_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_table_info: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 2455 | my ($self, $dbh, $table) = (shift, shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 2455 | ▶ | return undef if !$dbh->can('table_info'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 2455 | my $sth = $dbh->table_info(undef, $table->schema, $table->name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 2455 | ▶ | while (my $info = $sth->fetchrow_hashref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 2455 | ▶ | next if !$self->_table_info_matches($table, $info); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2455 | return $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | sub _table_info_matches { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_info_matches: not called CC=2 SCAR=10.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my ($self, $table, $info) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 49 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | return $info->{TABLE_SCHEM} eq $table->schema | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | && $info->{TABLE_NAME} eq $table->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$info->{'TABLE_SCHEM'} eq $table->schema && $info->{'TABLE_NAME'} eq $table->name
MC/DC0%0/2
$info->{'TABLE_SCHEM'} eq $table->schema && $info->{'TABLE_NAME'} eq $table->name
$info->{'TABLE_SCHEM'} eq $table->schema
$info->{'TABLE_NAME'} eq $table->name
Truth table0%0/3
A && B
A= $info->{'TABLE_SCHEM'} eq $table->schemaB= $info->{'TABLE_NAME'} eq $table->name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | # override to mask warnings if needed (see mysql) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 3125 | ▶ | sub _dbh_column_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_column_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 3125 | my ($self, $dbh) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 3125 | return $dbh->column_info(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # If a coderef uses DBI->connect, this should get its connect info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | sub _try_infer_connect_info_from_coderef { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_infer_connect_info_from_coderef: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | my ($dsn, $user, $pass, $params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 49 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | local *DBI::connect = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | (undef, $dsn, $user, $pass, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $code->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | return ($dsn, $user, $pass, $params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 20751 | ▶ | sub dbh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbh: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 20751 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 20751 | return $self->schema->storage->dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 827 | ▶ | sub _table_is_view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_is_view: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 827 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 827 | ▶ | my $info = $self->_dbh_table_info($self->dbh, $table) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 827 | return $info->{TABLE_TYPE} eq 'VIEW'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | L<DBIx::Class::Schema::Loader> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | See L<DBIx::Class::Schema::Loader/AUTHORS>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 49 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # vim:et sts=4 sw=4 tw=0: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||