blib/lib/DBIx/QuickORM/WhereBuilder/RawSQL.pm

filter: Statementstmt 71.4% 25 / 35 Branchbran 50.0% 8 / 16 Conditioncond 44.4% 8 / 18 MC/DCmcdc 40.0% 4 / 10 Subroutinesub 75.0% 6 / 8 Podpod 100% 4 / 4 totaltotal 60.4% 55 / 91 CC 15 SCAR 20.1
CC
15
Cov
59%
can_build_where
11.3
can_build_where
11.3
build_where
4.1
CRAP 7.5
« blib/lib/DBIx/QuickORM/Handle.pm ↑ Summary blib/lib/DBIx/QuickORM/Role/Row.pm »
1 package DBIx::QuickORM::WhereBuilder::RawSQL;
2 306 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 306 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 306 our $VERSION = '0.000032';
6  
7 306 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 306 ▶use Role::Tiny::With qw/with/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 306 with 'DBIx::QuickORM::Role::WhereBuilder';
11  
12 =pod
13  
14 =encoding UTF-8
15  
16 =head1 NAME
17  
18 DBIx::QuickORM::WhereBuilder::RawSQL - A where that is SQL already.
19  
20 =head1 DESCRIPTION
21  
22 Takes a C<where> that is a plain string, used as SQL with no binds, or a
23 single C<sql()> marker (L<DBIx::QuickORM::Value>), used with its binds. It
24 declines everything else.
25  
26 =head1 SYNOPSIS
27  
28 use DBIx::QuickORM::Value qw/sql/;
29  
30 my @rows = $orm->handle('users')->where(sql('id > ?', 10))->all;
31  
32 =head1 PUBLIC METHODS
33  
34 =over 4
35  
36 =item $bool = DBIx::QuickORM::WhereBuilder::RawSQL->can_build_where($where)
37  
38 =item ($sql, \@binds) = DBIx::QuickORM::WhereBuilder::RawSQL->build_where($where, $source, $dialect)
39  
40 As L<DBIx::QuickORM::Role::WhereBuilder> describes. The SQL is wrapped in
41 parentheses. An empty string is no condition.
42  
43 =back
44  
45 =cut
46  
47 205 ▶sub can_build_where {
Subroutine can_build_where: called CC=6 SCAR=24.3
Pod documented
48 0 ▶ my $class = shift;
Subroutine can_build_where: not called CC=6 SCAR=24.3
Pod documented
49 0 my ($where) = @_;
50 0 ▶ return 1 if defined($where) && !ref($where);
Branch: 2 branches
BranchTrueFalseTotal
if defined $where and not ref $where 5 200 205
if defined $where and not ref $where 0 0 0
Condition50%3/6
defined $where and not ref $where
!ll&&!rl&&r
11995
defined $where and not ref $where
!ll&&!rl&&r
000
MC/DC100%2/2
defined $where and not ref $where
defined $where not ref $where
MC/DC0%0/2
defined $where and not ref $where
defined $where not ref $where
Truth table100%3/3
A and not(B)
A= defined $whereB= not ref $where
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= defined $whereB= not ref $where
ABresult
0X0
100
111
51 0 ▶ return blessed($where) && $where->isa('DBIx::QuickORM::Value') && $where->kind eq 'sql' ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
builtin::blessed($where) && $where->isa('DBIx::QuickORM::Value') && $where->kind eq 'sql' ? : 1 199 200
builtin::blessed($where) && $where->isa('DBIx::QuickORM::Value') && $where->kind eq 'sql' ? : 0 0 0
Condition41%5/12
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value") and $where->kind eq "sql"
!ll&&!rl&&r
19811
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value")
!ll&&!rl&&r
19802
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value") and $where->kind eq "sql"
!ll&&!rl&&r
000
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value")
!ll&&!rl&&r
000
MC/DC66%2/3
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value") and $where->kind eq "sql"
builtin::blessed($where) $where->isa("DBIx::QuickORM::Value") $where->kind eq "sql"
MC/DC0%0/3
builtin::blessed($where) and $where->isa("DBIx::QuickORM::Value") and $where->kind eq "sql"
builtin::blessed($where) $where->isa("DBIx::QuickORM::Value") $where->kind eq "sql"
Truth table75%3/4
A and B and C
A= builtin::blessed($where)B= $where->isa("DBIx::QuickORM::Value")C= $where->kind eq "sql"
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= builtin::blessed($where)B= $where->isa("DBIx::QuickORM::Value")C= $where->kind eq "sql"
ABCresult
0XX0
10X0
1100
1111
52 }
53  
54 6 ▶sub build_where {
Subroutine build_where: called CC=3 SCAR=14.2
Pod documented
55 0 ▶ my $class = shift;
Subroutine build_where: not called CC=3 SCAR=14.2
Pod documented
56 0 my ($where) = @_;
57 0 ▶ my ($sql, @binds) = ref($where) ? ($where->value, map { [undef, $_] } @{$where->binds}) : ($where);
Branch: 2 branches
BranchTrueFalseTotal
ref $where ? : 1 5 6
ref $where ? : 0 0 0
58 0 ▶ return length($sql) ? ("( $sql )", \@binds) : ('', []);
Branch: 2 branches
BranchTrueFalseTotal
length $sql ? : 5 1 6
length $sql ? : 0 0 0
59 }
60  
61 306 1;
62  
63 __END__
« blib/lib/DBIx/QuickORM/Handle.pm ↑ Summary blib/lib/DBIx/QuickORM/Role/Row.pm »