Smooth/Lookup/ident.pm

filter: Statementstmt 58.8% 20 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 44.0% 26 / 59 CC 8 SCAR 37.3
CC
8
Cov
41%
smooth__lookup__ident
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 41.6
« Smooth/Lookup/Util.pm ↑ Summary Smooth/Helper/ResultSet/Shortcut/AddColumn.pm »
1 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Lookup::ident;
6  
7 # ABSTRACT: Short intro
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.0104';
10  
11 1 ▶use parent 'DBIx::Class::Smooth::Lookup::Util';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use experimental qw/signatures postderef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ▶sub smooth__lookup__ident($self, $column, $value, @rest) {
Subroutine smooth__lookup__ident: not called CC=8 SCAR=42.8
Pod undocumented
16 0 $self->smooth__lookup_util__ensure_value_is_scalar('ident', $value);
17  
18 0 my($possible_relation, $possible_column) = split /\./, $value;
19 0 ▶ $possible_relation = undef if $possible_relation eq 'me';
Branch: 1 branch
BranchTrueFalseTotal
if $possible_relation eq "me" 0 0 0
20  
21 0 ▶ if($possible_relation && $possible_column) {
Branch: 1 branch
BranchTrueFalseTotal
if ($possible_relation and $possible_column) { } 0 0 0
Condition0%0/3
$possible_relation and $possible_column
!ll&&!rl&&r
000
MC/DC0%0/2
$possible_relation and $possible_column
$possible_relation $possible_column
Truth table0%0/3
A and B
A= $possible_relationB= $possible_column
ABresult
0X0
100
111
22 0 ▶ if($self->result_source->has_relationship($possible_relation)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result_source->has_relationship($possible_relation)) { } 0 0 0
23 0 ▶ if($self->result_source->relationship_info($possible_relation)->{'class'}->has_column($possible_column)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result_source->relationship_info($possible_relation)->{'class'}->has_column($possible_column)) { } 0 0 0
24 0 $value = "$possible_relation.$possible_column";
25 }
26 else {
27 0 confess "<ident> got '$value'; column '$possible_column' does not exist in '$possible_relation";
28 }
29 }
30 else {
31 0 confess "<ident> got '$value', relation '$possible_relation' does not exist in the current result source";
32 }
33 }
34 else {
35 0 ▶ $possible_column = $possible_relation if !$possible_column;
Branch: 1 branch
BranchTrueFalseTotal
unless $possible_column 0 0 0
36 0 ▶ if($self->result_source->has_column($possible_column)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result_source->has_column($possible_column)) { } 0 0 0
37 0 $value = $self->current_source_alias . ".$possible_column";
38 }
39 else {
40 0 confess "<ident> got '$value', column '$possible_column' does not exist in the current result source"
41 }
42 }
43  
44 0 return { sql_operator => '=', value => $self->result_source->storage->sql_maker->_quote($value), quote_value => 0 };
45 }
46  
47 1 1;
48  
49 __END__
50  
51 =pod
52  
53 =encoding UTF-8
54  
55 =head1 NAME
56  
57 DBIx::Class::Smooth::Lookup::ident - Short intro
58  
59 =head1 VERSION
60  
61 Version 0.0104, released 2020-08-30.
62  
63 =head1 SOURCE
64  
65 L<https://github.com/Csson/p5-DBIx-Class-Smooth>
66  
67 =head1 HOMEPAGE
68  
69 L<https://metacpan.org/release/DBIx-Class-Smooth>
70  
71 =head1 AUTHOR
72  
73 Erik Carlsson <info@code301.com>
74  
75 =head1 COPYRIGHT AND LICENSE
76  
77 This software is copyright (c) 2018 by Erik Carlsson.
78  
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81  
82 =cut
« Smooth/Lookup/Util.pm ↑ Summary Smooth/Helper/ResultSet/Shortcut/AddColumn.pm »