| 1 | package DBIO::PostgreSQL::Extension; | ||||||||||||||||||||
| 2 | # ABSTRACT: The extension class of a PostgreSQL extension without rules, and the driver's table of the family's classes | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 124 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 124 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 124 | our $VERSION = '0.900007'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 124 | ▶ | use base 'DBIO::Extension'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | # The driver's fixed table of the extensions the family ships a class for | ||||||||||||||||||||
| 12 | # (ADR 0066 section 1.2): the engine's name to [ class, distribution ]. The | ||||||||||||||||||||
| 13 | # table maps names to existing classes, nothing is derived from a name. A | ||||||||||||||||||||
| 14 | # declaration that names a class of its own wins over it. | ||||||||||||||||||||
| 15 | 124 | our %FAMILY = ( | |||||||||||||||||||
| 16 | age => [ 'DBIO::PostgreSQL::Age::Extension', 'DBIO-PostgreSQL-Age' ], | ||||||||||||||||||||
| 17 | postgis => [ 'DBIO::PostgreSQL::PostGIS::Extension', 'DBIO-PostgreSQL-PostGIS' ], | ||||||||||||||||||||
| 18 | postgis_topology => [ 'DBIO::PostgreSQL::PostGIS::Topology::Extension', 'DBIO-PostgreSQL-PostGIS' ], | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 87 | ▶ | sub extension_interface { 1 } | ||||||||||||||||||
|
Subroutine
extension_interface: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 44 | ▶ | sub driver { 'DBIO::PostgreSQL' } | ||||||||||||||||||
|
Subroutine
driver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 92 | ▶ | sub family_class { | ||||||||||||||||||
|
Subroutine
family_class: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||
| 29 | 92 | my ($class, $name) = @_; | |||||||||||||||||||
| 30 | 92 | ▶ | my $entry = $FAMILY{$name // ''} or return; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$name // ""
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||
| 31 | 6 | return @$entry; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 272 | ▶ | sub resolve_list { | ||||||||||||||||||
|
Subroutine
resolve_list: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||
| 36 | 272 | my ($class, $schema, %opt) = @_; | |||||||||||||||||||
| 37 | 272 | ▶ | return undef unless $schema; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 271 | require DBIO::PostgreSQL::DDL; | |||||||||||||||||||
| 40 | 271 | ▶ | my $schemas = DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extension_schemas') // {}; | ||||||||||||||||||
|
Condition50%1/2
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas") // {}
MC/DC0%0/1
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas") // {}
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas")
Truth table50%1/2
A
A= DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas")
| |||||||||||||||||||||
| 41 | 271 | ▶ | my $classes = DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extension_classes') // {}; | ||||||||||||||||||
|
Condition50%1/2
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes") // {}
MC/DC0%0/1
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes") // {}
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes")
Truth table50%1/2
A
A= DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes")
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 271 | my @declaration; | |||||||||||||||||||
| 44 | 271 | for my $name (DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extensions')) { | |||||||||||||||||||
| 45 | 153 | my %options; | |||||||||||||||||||
| 46 | 153 | ▶ | $options{schema} = $schemas->{$name} if defined $schemas->{$name}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 153 | ▶ | $options{class} = $classes->{$name} if defined $classes->{$name}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 153 | ▶ | push @declaration, $name, (%options ? \%options : ()); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 271 | ▶ | return undef unless @declaration; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 100 | require DBIO::Extension::List; | |||||||||||||||||||
| 53 | my $list = DBIO::Extension::List->new( | ||||||||||||||||||||
| 54 | declaration => \@declaration, | ||||||||||||||||||||
| 55 | 87 | ▶ | class_table => sub { $class->family_class($_[0]) }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 56 | 100 | plain_class => __PACKAGE__, | |||||||||||||||||||
| 57 | ); | ||||||||||||||||||||
| 58 | 94 | ▶ | $list->check_driver('DBIO::PostgreSQL') if $opt{check_driver} // 1; | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$opt{"check_driver"} // 1
MC/DC100%1/1
$opt{"check_driver"} // 1
$opt{"check_driver"}
Truth table100%2/2
A
A= $opt{"check_driver"}
| |||||||||||||||||||||
| 59 | 92 | return $list; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 71 | ▶ | sub driver_helpers { | ||||||||||||||||||
|
Subroutine
driver_helpers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 64 | 71 | require DBIO::PostgreSQL::Util; | |||||||||||||||||||
| 65 | 71 | require DBIO::PostgreSQL::Introspect; | |||||||||||||||||||
| 66 | 71 | ▶ | my $key = sub { @_ > 1 ? DBIO::PostgreSQL::Introspect->qualified_key(@_) : $_[0] }; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 67 | return { | ||||||||||||||||||||
| 68 | quote_ident => \&DBIO::PostgreSQL::Util::quote_ident, | ||||||||||||||||||||
| 69 | quote_qualified => \&DBIO::PostgreSQL::Util::quote_qualified, | ||||||||||||||||||||
| 70 | 1 | ▶ | qualified_key => sub { DBIO::PostgreSQL::Introspect->qualified_key(@_) }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 71 | 47 | ▶ | schema => sub { [ schema => $_[0] ] }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 72 | 2 | ▶ | table => sub { [ table => $key->(@_) ] }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | 1 | ▶ | type => sub { [ type => $key->(@_) ] }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 74 | 94 | ▶ | column => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 75 | 94 | my $column = pop; | |||||||||||||||||||
| 76 | 94 | return [ column => $key->(@_), $column ]; | |||||||||||||||||||
| 77 | }, | ||||||||||||||||||||
| 78 | 71 | }; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 124 | 1; | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||