| 1 | package DBIO::Storage::DBI::AutoCast; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Storage component for RDBMS requiring explicit placeholder typing | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use base qw/DBIO::Storage::DBI/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | __PACKAGE__->mk_group_accessors('simple' => 'auto_cast' ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | sub _prep_for_execute { | ||||||||||||||||||||||||||
|
Subroutine
_prep_for_execute: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 17 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | my ($sql, $bind) = $self->next::method (@_); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # If we're using ::NoBindVars, there are no binds by this point so this code | ||||||||||||||||||||||||||||
| 22 | # gets skipped. | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | if ($self->auto_cast && @$bind) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->auto_cast and @$bind
MC/DC50%1/2
$self->auto_cast and @$bind
$self->auto_cast
@$bind
Truth table66%2/3
A and B
A= $self->auto_castB= @$bind
| |||||||||||||||||||||||||||||
| 24 | 1 | my $new_sql; | |||||||||||||||||||||||||||
| 25 | 1 | my @sql_part = split /\?/, $sql, scalar @$bind + 1; | |||||||||||||||||||||||||||
| 26 | 1 | for (@$bind) { | |||||||||||||||||||||||||||
| 27 | 2 | my $cast_type = $self->_native_data_type($_->[0]{sqlt_datatype}); | |||||||||||||||||||||||||||
| 28 | 2 | ▶ | $new_sql .= shift(@sql_part) . ($cast_type ? "CAST(? AS $cast_type)" : '?'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 1 | $sql = $new_sql . shift @sql_part; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | return ($sql, $bind); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub connect_call_set_auto_cast { | ||||||||||||||||||||||||||
|
Subroutine
connect_call_set_auto_cast: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | 1 | $self->auto_cast(1); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | 1; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||