| 1 | package DBIO::MySQL::Introspect; | ||||||||||||||||||||
| 2 | # ABSTRACT: Introspect a MySQL/MariaDB database via information_schema | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 42 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 42 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 42 | our $VERSION = '0.900007'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 42 | ▶ | use base 'DBIO::Introspect::Base'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 42 | ▶ | use DBIO::MySQL::Introspect::Tables; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 42 | ▶ | use DBIO::MySQL::Introspect::Columns; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 42 | ▶ | use DBIO::MySQL::Introspect::Indexes; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 42 | ▶ | use DBIO::MySQL::Introspect::ForeignKeys; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub _build_model { | ||||||||||||||||||
|
Subroutine
_build_model: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 18 | 0 | my ($self) = @_; | |||||||||||||||||||
| 19 | 0 | my $dbh = $self->dbh; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | my $tables = DBIO::MySQL::Introspect::Tables->fetch($dbh); | |||||||||||||||||||
| 22 | return { | ||||||||||||||||||||
| 23 | 0 | tables => $tables, | |||||||||||||||||||
| 24 | columns => DBIO::MySQL::Introspect::Columns->fetch($dbh, $tables), | ||||||||||||||||||||
| 25 | indexes => DBIO::MySQL::Introspect::Indexes->fetch($dbh, $tables), | ||||||||||||||||||||
| 26 | foreign_keys => DBIO::MySQL::Introspect::ForeignKeys->fetch($dbh, $tables), | ||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | ▶ | sub view_definition { | ||||||||||||||||||
|
Subroutine
view_definition: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 31 | 0 | my ($self, $key) = @_; | |||||||||||||||||||
| 32 | 0 | my $model = $self->model; | |||||||||||||||||||
| 33 | 0 | ▶ | my $tbl = $model->{tables}{$key} // {}; | ||||||||||||||||||
|
Condition0%0/2
$model->{"tables"}{$key} // {}
MC/DC0%0/1
$model->{"tables"}{$key} // {}
$model->{"tables"}{$key}
Truth table0%0/2
A
A= $model->{"tables"}{$key}
| |||||||||||||||||||||
| 34 | 0 | ▶ | return undef unless ($tbl->{kind} // '') eq 'view'; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$tbl->{"kind"} // ""
MC/DC0%0/1
$tbl->{"kind"} // ""
$tbl->{"kind"}
Truth table0%0/2
A
A= $tbl->{"kind"}
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | my ($def) = $self->dbh->selectrow_array( | |||||||||||||||||||
| 37 | q{SELECT view_definition FROM information_schema.views | ||||||||||||||||||||
| 38 | WHERE table_schema = DATABASE() AND table_name = ?}, | ||||||||||||||||||||
| 39 | undef, $key, | ||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||
| 41 | 0 | return $def; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 4 | ▶ | sub result_class_extra_statements { | ||||||||||||||||||
|
Subroutine
result_class_extra_statements: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||
| 45 | 4 | my ($self, $key) = @_; | |||||||||||||||||||
| 46 | 4 | my $model = $self->model; | |||||||||||||||||||
| 47 | 4 | ▶ | my $tbl = $model->{tables}{$key} // {}; | ||||||||||||||||||
|
Condition50%1/2
$model->{"tables"}{$key} // {}
MC/DC0%0/1
$model->{"tables"}{$key} // {}
$model->{"tables"}{$key}
Truth table50%1/2
A
A= $model->{"tables"}{$key}
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | # source_info is a plain setter -- emit ONE statement, a second call | ||||||||||||||||||||
| 50 | # would replace the first | ||||||||||||||||||||
| 51 | 4 | my %info; | |||||||||||||||||||
| 52 | 4 | ▶ | $info{mysql_engine} = $tbl->{engine} if $tbl->{engine}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 4 | ▶ | $info{mysql_collation} = $tbl->{table_collation} if $tbl->{table_collation}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 4 | ▶ | return %info ? ([ source_info => \%info ]) : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 42 | 1; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||