| 1 | package Puzzle::DBI; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use base 'DBIx::Class::Schema'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use DBIx::Class::Schema::Loader; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 10 | 0 | my $proto = shift; | |||||||||||||||||||
| 11 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 12 | 0 | my $dsn = shift; | |||||||||||||||||||
| 13 | 0 | my $user = shift; | |||||||||||||||||||
| 14 | 0 | my $password = shift; | |||||||||||||||||||
| 15 | 0 | ▶ | my $schema = shift || 'DBIx::Class::Schema::Loader'; | ||||||||||||||||||
|
Condition0%0/2
shift() || 'DBIx::Class::Schema::Loader'
MC/DC0%0/1
shift() || 'DBIx::Class::Schema::Loader'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 16 | 0 | my $s = $schema->connect($dsn,$user,$password); | |||||||||||||||||||
| 17 | 0 | bless $s, $class; | |||||||||||||||||||
| 18 | 0 | return $s; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub row2hash { | ||||||||||||||||||
|
Subroutine
row2hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | my $selft = shift; | |||||||||||||||||||
| 23 | 0 | my $rs = shift; | |||||||||||||||||||
| 24 | 0 | my $include_columns = shift; | |||||||||||||||||||
| 25 | 0 | my @columns = ($rs->columns, @$include_columns); | |||||||||||||||||||
| 26 | 0 | return {map { $rs->table.'.'.$_ => $rs->get_column($_) } @columns}; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | sub rs2aoh { | ||||||||||||||||||
|
Subroutine
rs2aoh: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||
| 31 | 0 | my $rs = shift; | |||||||||||||||||||
| 32 | 0 | my $include_columns = shift; | |||||||||||||||||||
| 33 | 0 | my @ret; | |||||||||||||||||||
| 34 | 0 | ▶ | while (my $row = $rs->next) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 0 | push @ret, $self->row2hash($row,$include_columns); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | 0 | return \@ret; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =head rs2hash() | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | Return an hashref where every key is the primary key value or a contatenation | ||||||||||||||||||||
| 43 | of primary keys and value is an hashref with record elements | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub rs2hash { | ||||||||||||||||||
|
Subroutine
rs2hash: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||||||||||
| 49 | 0 | my $rs = shift; | |||||||||||||||||||
| 50 | 0 | my $include_columns = shift; | |||||||||||||||||||
| 51 | 0 | my $ret = {}; | |||||||||||||||||||
| 52 | 0 | my @pk = $rs->result_source->primary_columns; | |||||||||||||||||||
| 53 | 0 | ▶ | while (my $row = $rs->next) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | my $key = scalar(@pk) == 1 | ||||||||||||||||||||
| 55 | ? $row->get_column($pk[0]) . '' | ||||||||||||||||||||
| 56 | 0 | ▶ | : join('-',map {$row->$_} @pk); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | $ret->{$key} = $self->row2hash($row,$include_columns); | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | 0 | return $ret; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||
| 63 | |||||||||||||||||||||