| 1 | package DBIO::SQLite::Extension; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: The extension class of a SQLite extension without rules, and the driver's table of the family's classes | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 209 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 209 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 209 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 209 | ▶ | 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 | 209 | our %FAMILY = ( | |||||||||||||||||||||||||||
| 16 | fts5 => [ 'DBIO::SQLite::Extension::FTS5', 'DBIO-SQLite' ], | ||||||||||||||||||||||||||||
| 17 | rtree => [ 'DBIO::SQLite::Extension::RTree', 'DBIO-SQLite' ], | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 83 | ▶ | sub extension_interface { 1 } | ||||||||||||||||||||||||||
|
Subroutine
extension_interface: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 46 | ▶ | sub driver { 'DBIO::SQLite' } | ||||||||||||||||||||||||||
|
Subroutine
driver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 67 | ▶ | sub activation { | ||||||||||||||||||||||||||
|
Subroutine
activation: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 67 | my ($class, $ctx) = @_; | |||||||||||||||||||||||||||
| 29 | 67 | ▶ | my $self = $ctx->{self} || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ctx->{'self'} || {}
MC/DC0%0/1
$ctx->{'self'} || {}
$ctx->{'self'}
Truth table50%1/2
A
A= $ctx->{'self'}
| |||||||||||||||||||||||||||||
| 30 | 67 | ▶ | my $library = ($self->{options} || {})->{library}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'options'} || {}
MC/DC0%0/1
$self->{'options'} || {}
$self->{'options'}
Truth table50%1/2
A
A= $self->{'options'}
| |||||||||||||||||||||||||||||
| 31 | 67 | ▶ | return undef unless defined $library; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 14 | return { load => { $self->{name} => $library } }; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 73 | ▶ | sub family_class { | ||||||||||||||||||||||||||
|
Subroutine
family_class: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 73 | my ($class, $name) = @_; | |||||||||||||||||||||||||||
| 38 | 73 | ▶ | 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
| |||||||||||||||||||||||||||||
| 39 | 44 | return @$entry; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 1704 | ▶ | sub resolve_list { | ||||||||||||||||||||||||||
|
Subroutine
resolve_list: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 1704 | my ($class, $schema, %opt) = @_; | |||||||||||||||||||||||||||
| 45 | 1704 | ▶ | return undef unless $schema; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1703 | ▶ | my $options = _schema_decl($schema, 'sqlite_extension_options') // {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
_schema_decl($schema, "sqlite_extension_options") // {}
MC/DC100%1/1
_schema_decl($schema, "sqlite_extension_options") // {}
_schema_decl($schema, "sqlite_extension_options")
Truth table100%2/2
A
A= _schema_decl($schema, "sqlite_extension_options")
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1703 | my @declaration; | |||||||||||||||||||||||||||
| 50 | 1703 | for my $name (_schema_decl($schema, 'sqlite_extensions')) { | |||||||||||||||||||||||||||
| 51 | 92 | my $own = $options->{$name}; | |||||||||||||||||||||||||||
| 52 | 92 | ▶ | push @declaration, $name, ($own && %$own ? { %$own } : ()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$own and %$own
MC/DC50%1/2
$own and %$own
$own
%$own
Truth table66%2/3
A and B
A= $ownB= %$own
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 1703 | ▶ | return undef unless @declaration; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 59 | require DBIO::Extension::List; | |||||||||||||||||||||||||||
| 57 | my $list = DBIO::Extension::List->new( | ||||||||||||||||||||||||||||
| 58 | declaration => \@declaration, | ||||||||||||||||||||||||||||
| 59 | 67 | ▶ | class_table => sub { $class->family_class($_[0]) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 59 | plain_class => __PACKAGE__, | |||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | 55 | ▶ | $list->check_driver('DBIO::SQLite') 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"}
| |||||||||||||||||||||||||||||
| 63 | 53 | return $list; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # A schema class that does not load the DBIO::SQLite component declares none. | ||||||||||||||||||||||||||||
| 67 | 3406 | ▶ | sub _schema_decl { | ||||||||||||||||||||||||||
|
Subroutine
_schema_decl: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 68 | 3406 | my ($schema, $method) = @_; | |||||||||||||||||||||||||||
| 69 | 3406 | ▶ | return $schema->can($method) ? $schema->$method : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 53 | ▶ | sub driver_helpers { | ||||||||||||||||||||||||||
|
Subroutine
driver_helpers: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 53 | require DBIO::SQLite::Util; | |||||||||||||||||||||||||||
| 75 | return { | ||||||||||||||||||||||||||||
| 76 | quote_ident => \&DBIO::SQLite::Util::quote_identifier, | ||||||||||||||||||||||||||||
| 77 | 432 | ▶ | table => sub { [ table => $_[0] ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | column => sub { [ column => $_[0], $_[1] ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 79 | 53 | }; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 209 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||