lib/DB/Object/Query/Clause.pm

filter: Statementstmt 19.0% 25 / 131 Branchbran 0.0% 0 / 60 Conditioncond 0.0% 0 / 62 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 33.3% 8 / 24 Podpod 71.4% 10 / 14 totaltotal 13.2% 43 / 324 CC 57 SCAR 56.3
CC
57
Cov
10%
merge
702.0
as_string
182.0
THAW
110.0
CRAP 279.5
« lib/DB/Object/SQLite/Tables.pm ↑ Summary lib/DB/Object/Mysql/Statement.pm »
1 ##----------------------------------------------------------------------------
2 ## Database Object Interface - ~/lib/DB/Object/Query/Clause.pm
3 ## Version v1.1.2
4 ## Copyright(c) 2026 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2023/07/08
7 ## Modified 2026/08/05
8 ## All rights reserved
9 ##
10 ## This program is free software; you can redistribute it and/or modify it
11 ## under the same terms as Perl itself.##
12 ##----------------------------------------------------------------------------##
13 package DB::Object::Query::Clause;
14 BEGIN
15 4 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶ use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 warnings::register_categories( 'DB::Object' );
19 4 ▶ use parent qw( DB::Object::Query::Elements );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶ use vars qw( $VERSION $EXCEPTION_CLASS );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶ use overload (
Subroutine BEGIN: called CC=1 SCAR=0.2
22 '""' => 'as_string',
23 0 ▶ 'bool' => sub{1},
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 4 fallback => 1,
25 4 );
26 4 our $EXCEPTION_CLASS = $DB::Object::EXCEPTION_CLASS;
27 4 our $VERSION = 'v1.1.2';
28 };
29  
30 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 sub init
34 0 ▶{
Subroutine init: not called CC=2 SCAR=17.9
Pod documented
35 0 my $self = shift( @_ );
36 0 $self->{generic} = '';
37 0 $self->{operator} = '';
38 0 $self->{type} = '';
39 0 $self->{value} = '';
40 0 $self->{_init_strict_use_sub} = 1;
41 # $self->{fields} = [];
42 0 $self->{_exception_class} = $EXCEPTION_CLASS;
43 0 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 0 0
44 0 $self->{_clause_reset} = '';
45 0 $self->{_fields} = [qw( generic operator type value )];
46 0 return( $self );
47 }
48  
49 sub as_string
50 0 ▶{
Subroutine as_string: not called CC=13 SCAR=52.0
Pod documented
51 # no overloading;
52 0 my $self = shift( @_ );
53 0 my $fields = $self->fields;
54 0 ▶ if( $self->generic->length && $self->query_object->table_object->use_bind )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->generic->length and $self->query_object->table_object->use_bind) 0 0 0
Condition0%0/3
$self->generic->length and $self->query_object->table_object->use_bind
!ll&&!rl&&r
000
MC/DC0%0/2
$self->generic->length and $self->query_object->table_object->use_bind
$self->generic->length $self->query_object->table_object->use_bind
Truth table0%0/3
A and B
A= $self->generic->lengthB= $self->query_object->table_object->use_bind
ABresult
0X0
100
111
55 {
56 0 ▶ return( $self->{_cache_clause_generic} ) if( $self->{_cache_clause_generic} && !CORE::length( $self->{_reset} // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_cache_clause_generic"} and not CORE::length($self->{"_reset"} // "") 0 0 0
Condition0%0/5
$self->{"_cache_clause_generic"} and not CORE::length($self->{"_reset"} // "")
!ll&&!rl&&r
000
$self->{"_reset"} // ""
l!l
00
MC/DC0%0/2
$self->{"_cache_clause_generic"} and not CORE::length($self->{"_reset"} // "")
$self->{"_cache_clause_generic"} $self->{"_reset"}
Truth table0%0/3
A and not(B)
A= $self->{"_cache_clause_generic"}B= $self->{"_reset"}
ABresult
0X0
110
101
57 0 CORE::delete( $self->{_reset} );
58 0 ▶ return( $self->{_cache_clause_generic} = $self->generic ) if( !$fields->length );
Branch: 1 branch
BranchTrueFalseTotal
unless $fields->length 0 0 0
59 0 return( $self->{_cache_clause_generic} = Module::Generic::Scalar->new( CORE::sprintf( $self->generic, @$fields ) ) );
60 }
61 0 ▶ return( $self->{_cache_clause} ) if( $self->{_cache_clause} && !CORE::length( $self->{_reset} // '' ) );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_cache_clause"} and not CORE::length($self->{"_reset"} // "") 0 0 0
Condition0%0/5
$self->{"_cache_clause"} and not CORE::length($self->{"_reset"} // "")
!ll&&!rl&&r
000
$self->{"_reset"} // ""
l!l
00
MC/DC0%0/2
$self->{"_cache_clause"} and not CORE::length($self->{"_reset"} // "")
$self->{"_cache_clause"} $self->{"_reset"}
Truth table0%0/3
A and not(B)
A= $self->{"_cache_clause"}B= $self->{"_reset"}
ABresult
0X0
110
101
62 0 CORE::delete( $self->{_reset} );
63 0 my $str = $self->value;
64 0 ▶ return( $self->{_cache_clause} = $str ) if( !length( $str // '' ) || $str !~ /(?<!\%)\%\s\d/ );
Branch: 1 branch
BranchTrueFalseTotal
unless CORE::length($str // "") and $str =~ /(?<!\%)\%\s\d/ 0 0 0
Condition0%0/5
CORE::length($str // "") and $str =~ /(?<!\%)\%\s\d/
!ll&&!rl&&r
000
$str // ""
l!l
00
MC/DC0%0/2
CORE::length($str // "") and $str =~ /(?<!\%)\%\s\d/
$str $str =~ /(?<!\%)\%\s\d/
Truth table0%0/3
A and B
A= $strB= $str =~ /(?<!\%)\%\s\d/
ABresult
0X0
100
111
65 # Stringification of the fields will automatically format them properly, ie with a table prefix, schema prefix, database prefix as necessary
66 0 return( $self->{_cache_clause} = Module::Generic::Scalar->new( CORE::sprintf( $str, @$fields ) ) );
67 }
68  
69 # sub bind
70 # {
71 # return( shift->_set_get_class( 'bind',
72 # {
73 # # The sql types of the value bound to the placeholders
74 # types => { type => 'array_as_object' },
75 # # The values bound to the placeholders in the sql clause
76 # values => { type => 'array_as_object' },
77 # }, @_ ) );
78 # }
79 0 ▶sub bind { warn( "Call to ", ref( $_[0] ), "->bind is now deprecated." ) if( warnings::enabled( 'DB::Object' ) ); }
Subroutine bind: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled("DB::Object") 0 0 0
80  
81 # sub fields { return( shift->_set_get_array_as_object( 'fields', @_ ) ); }
82 # NOTE: sub fields is inherited from DB::Object::Query::Elements
83  
84 0 ▶sub generic { return( shift->_set_get_scalar_as_object( 'generic', @_ ) ); }
Subroutine generic: not called CC=1 SCAR=6.9
Pod documented
85  
86 0 ▶sub length { return( shift->value->length ); }
Subroutine length: not called CC=1 SCAR=6.9
Pod documented
87  
88 0 ▶sub metadata { return( shift->_set_get_hash_as_object( 'metadata', @_ ) ); }
Subroutine metadata: not called CC=1 SCAR=6.9
Pod documented
89 # sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); }
90  
91 # NOTE: sub merge supersedes the one inherited from DB::Object::Query::Elements
92 # This takes or or more values and merge its clauses and the binded parameters
93 sub merge
94 0 ▶{
Subroutine merge: not called CC=26 SCAR=65.5
Pod documented
95 0 my $self = shift( @_ );
96 0 ▶ if( @_ )
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
97 {
98 # By default
99 0 my $op = 'AND';
100 0 my @params = ();
101 # $clause->merge( $dbh->OR( $clause1, $clause2, $clause3 ) );
102 # or just
103 # $clause->merge( $clause1, $clause2, $clause3 );
104 0 ▶ if( $self->_is_object( $_[0] ) && $_[0]->isa( 'DB::Object::Operator' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_object($_[0]) and $_[0]->isa('DB::Object::Operator')) { } 0 0 0
Condition0%0/3
$self->_is_object($_[0]) and $_[0]->isa("DB::Object::Operator")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_object($_[0]) and $_[0]->isa("DB::Object::Operator")
$self->_is_object($_[0]) $_[0]->isa("DB::Object::Operator")
Truth table0%0/3
A and B
A= $self->_is_object($_[0])B= $_[0]->isa("DB::Object::Operator")
ABresult
0X0
100
111
105 {
106 0 my $op_obj = shift( @_ );
107 0 ▶ return( $self->error( "Database Object operator provided is invalid. It should be either an AND or OR." ) ) if( $op_obj->operator ne 'AND' and $op_obj->operator ne 'OR' and $op_obj->operator ne 'NOT' );
Branch: 1 branch
BranchTrueFalseTotal
if $op_obj->operator ne "AND" and $op_obj->operator ne "OR" and $op_obj->operator ne "NOT" 0 0 0
Condition0%0/6
$op_obj->operator ne "AND" and $op_obj->operator ne "OR" and $op_obj->operator ne "NOT"
!ll&&!rl&&r
000
$op_obj->operator ne "AND" and $op_obj->operator ne "OR"
!ll&&!rl&&r
000
MC/DC0%0/3
$op_obj->operator ne "AND" and $op_obj->operator ne "OR" and $op_obj->operator ne "NOT"
$op_obj->operator ne "AND" $op_obj->operator ne "OR" $op_obj->operator ne "NOT"
Truth table0%0/4
A and B and C
A= $op_obj->operator ne "AND"B= $op_obj->operator ne "OR"C= $op_obj->operator ne "NOT"
ABCresult
0XX0
10X0
1100
1111
108 0 $op = $op_obj->operator;
109 0 @params = grep( !$self->_is_a( 'DB::Object::Fields::Unknown' ), $op_obj->value );
110 }
111 else
112 {
113 0 @params = @_;
114 }
115  
116 0 my @clause = ();
117 0 ▶ @clause = ( $self->value ) if( $self->value->length > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->value->length > 0 0 0 0
118 0 my @generic = ();
119 0 ▶ @generic = ( $self->generic ) if( $self->generic->length > 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->generic->length > 0 0 0 0
120 0 my $elems = $self->elements;
121 0 foreach my $this ( @params )
122 {
123 # Safeguard against garbage
124 # Special treatment for DB::Object::Fields::Overloaded who are already formatted
125 0 ▶ if( $self->_is_a( $this => [qw( DB::Object::Fields::Overloaded DB::Object::Expression )] ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_a($this, ["DB::Object::Fields::Overloaded", "DB::Object::Expression"])) 0 0 0
126 {
127 0 push( @clause, $this );
128 # Also transfer any bind element so execute() can find the placeholder types
129 0 ▶ $elems->push( $this ) if( $self->_is_a( $this => 'DB::Object::Fields::Overloaded' ) && $this->placeholder );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_a($this, "DB::Object::Fields::Overloaded") and $this->placeholder 0 0 0
Condition0%0/3
$self->_is_a($this, "DB::Object::Fields::Overloaded") and $this->placeholder
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_a($this, "DB::Object::Fields::Overloaded") and $this->placeholder
$self->_is_a($this, "DB::Object::Fields::Overloaded") $this->placeholder
Truth table0%0/3
A and B
A= $self->_is_a($this, "DB::Object::Fields::Overloaded")B= $this->placeholder
ABresult
0X0
100
111
130 0 next;
131 }
132  
133 0 ▶ next if( !$self->_is_a( $this => 'DB::Object::Query::Clause' ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($this, "DB::Object::Query::Clause") 0 0 0
134 # First check we even have a clause, otherwise skip
135 0 ▶ if( !$this->value->length )
Branch: 1 branch
BranchTrueFalseTotal
unless ($this->value->length) 0 0 0
136 {
137 0 CORE::next;
138 }
139 # where, order, group, limit etc...
140 0 ▶ if( $self->type->length && $this->type->length && $this->type ne $self->type )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type->length and $this->type->length and $this->type ne $self->type) 0 0 0
Condition0%0/6
$self->type->length and $this->type->length and $this->type ne $self->type
!ll&&!rl&&r
000
$self->type->length and $this->type->length
!ll&&!rl&&r
000
MC/DC0%0/3
$self->type->length and $this->type->length and $this->type ne $self->type
$self->type->length $this->type->length $this->type ne $self->type
Truth table0%0/4
A and B and C
A= $self->type->lengthB= $this->type->lengthC= $this->type ne $self->type
ABCresult
0XX0
10X0
1100
1111
141 {
142 0 return( $self->error( "This clause provided for merge is not of the same type \"", $this->type, "\" as ours \"", $self->type, "\"." ) );
143 }
144 # Possibly our type is empty and if so, we initiate it by using the type of the first object we find
145 # This makes it convenient to merge without having to set the type beforehand like so:
146 # $clause->type( 'where' );
147 # $clause->merge( $w1, $w2, $e3 );
148 # We can do instead
149 # $clause->merge( $w1, $w2, $e3 );
150 # And it will take the type from $w1
151 0 ▶ $self->type( $this->type ) if( !$self->type->length );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->type->length 0 0 0
152 0 ▶ if( !$this->operator->is_empty && $this->operator ne $op )
Branch: 1 branch
BranchTrueFalseTotal
if (not $this->operator->is_empty and $this->operator ne $op) { } 0 0 0
Condition0%0/3
not $this->operator->is_empty and $this->operator ne $op
!ll&&!rl&&r
000
MC/DC0%0/2
not $this->operator->is_empty and $this->operator ne $op
not $this->operator->is_empty $this->operator ne $op
Truth table0%0/3
not(A) and B
A= not $this->operator->is_emptyB= $this->operator ne $op
ABresult
0X0
100
111
153 {
154 0 CORE::push( @clause, '( ' . $this->value . ' )' );
155 }
156 else
157 {
158 0 CORE::push( @clause, $this->value );
159 }
160  
161 0 ▶ if( !$this->generic->is_empty )
Branch: 1 branch
BranchTrueFalseTotal
unless ($this->generic->is_empty) 0 0 0
162 {
163 0 ▶ if( !$this->operator->is_empty && $this->operator ne $op )
Branch: 1 branch
BranchTrueFalseTotal
if (not $this->operator->is_empty and $this->operator ne $op) { } 0 0 0
Condition0%0/3
not $this->operator->is_empty and $this->operator ne $op
!ll&&!rl&&r
000
MC/DC0%0/2
not $this->operator->is_empty and $this->operator ne $op
not $this->operator->is_empty $this->operator ne $op
Truth table0%0/3
not(A) and B
A= not $this->operator->is_emptyB= $this->operator ne $op
ABresult
0X0
100
111
164 {
165 0 CORE::push( @generic, '( ' . $this->generic . ' )' );
166 }
167 else
168 {
169 0 CORE::push( @generic, $this->generic );
170 }
171 }
172  
173 # we just stack them, and later we will sort them by their object property 'index' value.
174 $this->elements->for(sub
175 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
176 0 my( $i, $v ) = @_;
177 # This is perfectly ok. It just means there is nothing at this offset
178 0 ▶ if( !defined( $v ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v) 0 0 0
179 {
180 0 return;
181 }
182 # If an entry with same index is provided, it overwrite the previous one.
183 # elsif( $v->is_numbered )
184 # {
185 # $elems->[$i] = $v;
186 # }
187 # else
188 # {
189 # $elems->push( $v );
190 # }
191 0 $elems->push( $v );
192 0 });
193  
194 # $self->fields->push( @{$this->fields} ) if( $this->fields->length );
195 # $self->bind->types->push( @{$this->bind->types} ) if( $this->bind->types->length );
196 # $self->bind->values->push( @{$this->bind->values} ) if( $this->bind->values->length );
197 # $ref returned here is a DB::Object::Query::Clause::Metadata object made from Module::Generic::Hash
198 0 my $ref = $this->metadata;
199 0 my $hash = $self->metadata;
200 0 foreach my $k ( keys( %$ref ) )
201 {
202 0 ▶ $hash->{ $k } = $ref->{ $k } if( !CORE::exists( $hash->{ $k } ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hash->{$k} 0 0 0
203 }
204 0 $self->metadata( $hash );
205 }
206 0 $self->value( CORE::join( " $op ", @clause ) );
207 0 $self->generic( CORE::join( " $op ", @generic ) );
208 0 $self->operator( $op );
209 }
210 0 return( $self );
211 }
212  
213 0 ▶sub operator { return( shift->_set_get_scalar_as_object( 'operator', @_ ) ); }
Subroutine operator: not called CC=1 SCAR=6.9
Pod documented
214  
215 # NOTE: sub push is inherited from DB::Object::Query::Elements
216  
217 # NOTE: sub query_object is inherited from DB::Object::Query::Elements
218  
219 # NOTE: sub reset is inherited from DB::Object::Query::Elements
220  
221 # The clause type e.g. where, order, group, having, limit, etc
222 0 ▶sub type { return( shift->_set_get_scalar_as_object( 'type', @_ ) ); }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
223  
224 # NOTE: sub types is inherited from DB::Object::Query::Elements
225  
226 # The string value of the clause
227 0 ▶sub value { return( shift->_set_get_scalar_as_object( 'value', @_ ) ); }
Subroutine value: not called CC=1 SCAR=6.9
Pod documented
228  
229 # NOTE: sub values is inherited from DB::Object::Query::Elements
230  
231 sub FREEZE
232 0 ▶{
Subroutine FREEZE: not called CC=8 SCAR=42.8
Pod undocumented
233 0 my $self = CORE::shift( @_ );
234 0 ▶ my $serialiser = CORE::shift( @_ ) // '';
Condition0%0/2
shift @_ // ""
l!l
00
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
Aresult
11
00
235 0 my $class = CORE::ref( $self );
236  
237 # We keep a strict allow-list to avoid accidentally freezing DBI handles or other
238 # process-local state.
239 0 my @props = @{$self->{_fields}};
240  
241 0 my $hash = {};
242 0 foreach my $prop ( @props )
243 {
244 0 ▶ if( CORE::exists( $self->{ $prop } ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{$prop} and defined $self->{$prop} and ref $self->{$prop} ne "CODE") 0 0 0
Condition0%0/6
exists $self->{$prop} and defined $self->{$prop} and ref $self->{$prop} ne "CODE"
!ll&&!rl&&r
000
exists $self->{$prop} and defined $self->{$prop}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{$prop} and defined $self->{$prop} and ref $self->{$prop} ne "CODE"
exists $self->{$prop} defined $self->{$prop} ref $self->{$prop} ne "CODE"
Truth table0%0/4
A and B and C
A= exists $self->{$prop}B= defined $self->{$prop}C= ref $self->{$prop} ne "CODE"
ABCresult
0XX0
10X0
1100
1111
245 defined( $self->{ $prop } ) &&
246 CORE::ref( $self->{ $prop } ) ne 'CODE' )
247 {
248 0 $hash->{ $prop } = $self->{ $prop };
249 }
250 }
251  
252 # Return an array reference rather than a list so this works with Sereal and CBOR.
253 # Before Sereal version 4.023, Sereal did not support multiple values returned.
254 0 ▶ if( $serialiser eq 'Sereal' )
Branch: 1 branch
BranchTrueFalseTotal
if ($serialiser eq "Sereal") 0 0 0
255 {
256 0 require Sereal::Encoder;
257 0 require version;
258  
259 0 ▶ if( version->parse( Sereal::Encoder->VERSION ) < version->parse( '4.023' ) )
Branch: 1 branch
BranchTrueFalseTotal
if ("version"->parse("Sereal::Encoder"->VERSION) < "version"->parse("4.023")) 0 0 0
260 {
261 0 CORE::return( [$class, $hash] );
262 }
263 }
264  
265 # But Storable wants a list with the first element being the serialised element
266 0 CORE::return( $class, $hash );
267 }
268  
269 0 ▶sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); }
Subroutine STORABLE_freeze: not called CC=1 SCAR=6.9
Pod undocumented
270  
271 0 ▶sub STORABLE_thaw { return( shift->THAW( @_ ) ); }
Subroutine STORABLE_thaw: not called CC=1 SCAR=6.9
Pod undocumented
272  
273 sub THAW
274 0 ▶{
Subroutine THAW: not called CC=10 SCAR=47.0
Pod undocumented
275 # STORABLE_thaw would issue $cloning as the 2nd argument, while CBOR would issue
276 # 'CBOR' as the second value.
277 0 my( $self, undef, @args ) = @_;
278 0 ▶ my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args;
Branch: 1 branch
BranchTrueFalseTotal
scalar @args == 1 && ref $args[0] eq 'ARRAY' ? : 0 0 0
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1 ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
ABresult
0X0
100
111
279 0 ▶ my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self );
Branch: 1 branch
BranchTrueFalseTotal
defined $ref && ref $ref eq 'ARRAY' && scalar @$ref > 1 ? : 0 0 0
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
!ll&&!rl&&r
000
defined $ref and ref $ref eq "ARRAY"
!ll&&!rl&&r
000
ref $self or $self
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref ref $ref eq "ARRAY" scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self $self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A or B
A= ref $selfB= $self
ABresult
1X1
011
000
280 0 ▶ my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $ref eq 'ARRAY' ? : 0 0 0
281 0 my $new;
282 # Storable pattern requires to modify the object it created rather than returning a new one
283 0 ▶ if( CORE::ref( $self ) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
284 {
285 0 foreach( CORE::keys( %$hash ) )
286 {
287 0 $self->{ $_ } = CORE::delete( $hash->{ $_ } );
288 }
289 0 $new = $self;
290 }
291 else
292 {
293 0 $new = CORE::bless( $hash => $class );
294 }
295 0 CORE::return( $new );
296 }
297  
298 4 1;
299 # NOTE: POD
300 __END__
« lib/DB/Object/SQLite/Tables.pm ↑ Summary lib/DB/Object/Mysql/Statement.pm »