Branch Coverage

lib/DB/Object/Query.pm
Criterion Covered Total %
branch 26 690 3.7


line true false branch
33 1 0 unless exists $self->{'alias'}
34 1 0 unless exists $self->{'avoid'}
35 1 0 unless exists $self->{'binded'}
36 1 0 unless exists $self->{'binded_group'}
37 1 0 unless exists $self->{'binded_limit'}
38 1 0 unless exists $self->{'binded_order'}
39 1 0 unless exists $self->{'binded_types'}
40 1 0 unless exists $self->{'binded_values'}
41 1 0 unless exists $self->{'binded_where'}
42 1 0 unless exists $self->{'enhance'}
43 1 0 unless exists $self->{'from_table'}
44 1 0 unless exists $self->{'from_unixtime'}
45 1 0 unless exists $self->{'group_by'}
46 1 0 unless exists $self->{'join_fields'}
47 1 0 unless exists $self->{'left_join'}
48 1 0 unless exists $self->{'limit'}
49 1 0 unless exists $self->{'local'}
50 1 0 unless exists $self->{'order_by'}
51 1 0 unless exists $self->{'prepare_options'}
52 1 0 unless exists $self->{'reverse'}
53 1 0 unless exists $self->{'sorted'}
54 1 0 unless exists $self->{'table_alias'}
55 1 0 unless exists $self->{'table_object'}
56 1 0 unless exists $self->{'unix_timestamp'}
57 1 0 unless exists $self->{'where'}
59 0 1 unless $self->SUPER::init(@_)
99 0 0 if (@_)
102 0 0 unless $self->_is_hash($def)
105 0 0 unless $def->{$k}
108 0 0 if $def->{'sth'} and not $self->_is_object($def->{'sth'}) || $def->{'sth'}->isa('DB::Object::Statement')
120 0 0 if (scalar keys %$constant)
122 0 0 if $constant->{'sth'} and $self->_is_object($constant->{'sth'}) and $constant->{'sth'}->isa("DB::Object::Statement")
128 0 0 if @_
130 0 0 unless ($where)
134 0 0 unless ($where)
141 0 0 if scalar @$clauses
143 0 0 unless $self->where or $self->database_object->allow_bulk_delete
152 0 0 unless (defined wantarray)
154 0 0 unless $sth->execute
186 0 0 if @_
190 0 0 unless $opts->{'data'}
191 0 0 unless $opts->{'order'}
192 0 0 unless $opts->{'table'}
220 0 0 if (@$args and not @$args % 2)
224 0 0 if exists $$order{$args->[$i]}
228 0 0 unless @sorted
236 0 0 if (exists $data->{$_})
239 0 0 if ($self->_is_a($value, "${base_class}::Statement")) { }
0 0 elsif (exists $from_unix->{$_}) { }
0 0 elsif (exists $unixtime->{$_}) { }
0 0 elsif (ref $value eq 'SCALAR') { }
0 0 elsif ($value eq '?') { }
0 0 elsif ($struct->{$_} =~ /^\s*\bBLOB\b/i) { }
0 0 elsif (not $bind) { }
0 0 elsif ($value =~ /^\d+$/ and $struct->{$_} =~ /\bSET\(/i) { }
0 0 elsif ($value =~ /^\d+$/ and $struct->{$_} =~ /\bENUM\(/i and $query_type eq 'insert' || $query_type eq 'update') { }
0 0 elsif ($bind) { }
247 0 0 if ($bind) { }
260 0 0 if ($bind) { }
325 0 0 if ($prefix) { }
331 0 0 if ($` =~ /\s+(?:AS|FROM)\s+$/i) { }
0 0 elsif ($query_type eq 'select' and $prefix) { }
344 0 0 if $multi_db
352 0 0 if (not wantarray and scalar @{$self->{'_extra'};})
358 0 0 wantarray ? :
364 0 0 if $self->_is_array($_[0]) or $self->_is_hash($_[0]) or @_ % 2
366 0 0 if (not @arg and $data)
368 0 0 if ($self->_is_hash($data)) { }
0 0 elsif ($self->_is_array($data)) { }
378 0 0 if @arg and scalar(@arg) % 2
382 0 0 if ($arg{'data'} and not $data) { }
0 0 elsif ($self->_is_hash($data)) { }
395 0 0 unless ($info and scalar @$info)
430 0 0 unless exists $fields_ref->{$field}
435 0 0 if (exists $from_unixtime->{$field}) { }
0 0 elsif (ref $value eq 'SCALAR') { }
0 0 elsif (not $bind) { }
0 0 elsif ($value =~ /^\d+$/ and $struct->{$field} =~ /\bSET\(/i) { }
0 0 elsif ($bind) { }
437 0 0 if ($bind) { }
446 0 0 if $value eq "?"
458 0 0 if ($value eq '?') { }
0 0 elsif (lc $types->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
0 0 elsif ($self->_is_hash($value) and lc $types->{$field} eq 'jsonb' || lc $types->{$field} eq 'json') { }
461 0 0 if (lc $types->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
0 0 elsif (exists $types_const->{$field}) { }
483 0 0 lc $types->{$field} eq 'jsonb' ? :
501 0 0 if (lc $types->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
0 0 elsif (exists $types_const->{$field}) { }
518 0 0 if (lc $types->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
530 0 0 if scalar @types
544 0 0 $tbl_o->query_object->table_alias ? :
546 0 0 if ($opts->{'arg'})
548 0 0 unless $self->_is_array($opts->{'arg'})
550 0 0 if scalar @$arg and @$arg % 2
560 0 0 if scalar @$arg
562 0 0 unless defined $opts->{'time'}
564 0 0 if $opts->{'time'} =~ /^\d+$/
567 0 0 unless ($query_type)
574 0 0 if ($query_type ne "insert" and $query_type ne "delete" and $query_type ne "replace")
577 0 0 unless $alias and %$alias
590 0 0 unless (%default and %fields)
595 0 0 if ($query_type eq "select" and $enhance)
601 0 0 if ($structure{$field} =~ /^\s*(?:DATE(?:TIME)?|TIMESTAMP)\s*/i)
605 0 0 $prefix ? :
617 0 0 if ($self->_is_array($unix_time)) { }
0 0 elsif ($self->_is_hash($unix_time)) { }
626 0 0 if (%to_unixtime and scalar keys %to_unixtime)
630 0 0 if (exists $fields{$field})
633 0 0 $prefix ? :
645 0 0 if ($self->_is_array($avoid)) { }
0 0 elsif ($self->_is_hash($avoid)) { }
654 0 0 if (%avoid and scalar keys %avoid)
658 0 0 if (exists $fields{$field})
667 0 0 if ($self->_is_hash($alias))
672 0 0 if (exists $fields{$field}) { }
674 0 0 $prefix ? :
686 0 0 if (exists $fields{'last_name'} and exists $fields{'first_name'} and not exists $fields{'name'})
691 0 0 $prefix ? :
697 0 0 if (exists $default{'auth'} and not defined $arg{'auth'} or defined $arg{'auth'})
701 0 0 defined $arg{'auth'} ? :
704 0 0 if (exists $default{'status'} and not defined $default{'status'} or defined $arg{'status'})
708 0 0 defined $arg{'status'} ? :
713 0 0 if (exists $default{$data})
719 0 0 if ($self->_is_array($from_unix)) { }
0 0 elsif ($self->_is_hash($from_unix)) { }
748 0 0 if @_ == 1 and ref $_[0]
751 0 0 if (scalar keys %$constant)
753 0 0 if $constant->{'sth'} and $self->_is_object($constant->{'sth'}) and $constant->{'sth'}->isa("DB::Object::Statement")
758 0 0 if (not @arg and $data and $self->_is_hash($data)) { }
0 0 elsif ($data and ref $data eq "${base_class}::Statement") { }
767 0 0 if @arg
777 0 0 unless ($select)
781 0 0 if $structure->{$field} =~ /\b(AUTO_INCREMENT|SERIAL|nextval)\b/i and not $arg{$field}
784 0 0 if scalar @arg and not exists $arg{$field} and $null->{$field}
787 0 0 unless $self->getdefault({"table", $table, "arg", \@arg, "avoid", \@avoid})
794 0 0 if ($data and $self->_is_hash($data) and $self->binded_types->length)
799 0 0 $select ? :
800 0 0 if scalar @$clauses
809 0 0 unless (defined $sth)
813 0 0 unless (defined wantarray)
815 0 0 unless $sth->execute
833 0 0 if (length $limit->metadata->limit)
835 0 0 length $limit->metadata->offset ? :
837 0 0 if ($limit->metadata->offset eq '?' and $limit->metadata->limit eq '?' or $limit->metadata->limit eq '?') { }
842 0 0 length $limit->metadata->offset ? :
850 0 0 length $limit->metadata->offset ? :
865 0 0 if (@_)
869 0 0 if (scalar keys %$data)
875 0 0 wantarray ? :
0 0 unless $local and %$local
876 0 0 if wantarray
888 0 0 unless defined $o
889 0 0 unless $o->query_object($self)
915 0 0 unless ($self->{'query_reset'})
920 0 0 unless ($core_keys == $keys)
948 0 0 if (@_)
959 0 0 if (scalar keys %$constant)
961 0 0 if $constant->{'sth'} and $self->_is_object($constant->{'sth'}) and $constant->{'sth'}->isa("DB::Object::Statement")
964 0 0 $tbl_o->query_object->table_alias ? :
976 0 0 if (@_) { }
980 0 0 @_ == 1 && ref $_[0] ? :
981 0 0 if (ref $data eq 'SCALAR') { }
0 0 elsif ($self->_is_array($data)) { }
992 0 0 if (lc $alias->{$n} eq lc $data->[$i])
1000 0 0 $prefix ? :
0 0 scalar keys %$alias ? :
0 0 @$data ? :
1011 0 0 if (length $fields)
1018 0 0 if ($` =~ /\s+(?:AS|FROM)\s+$/i or not $field) { }
0 0 elsif ($prefix) { }
1031 0 0 if $multi_db
1035 0 0 if ($alias and %$alias)
1040 0 0 if (ref $alias->{$f} eq 'SCALAR') { }
0 0 elsif (exists $ok_ref->{$f} and $prefix) { }
0 0 elsif ($f =~ /\b(?:$ok_list)\b/ or $f =~ /\w\([^\)]*\)/) { }
1051 0 0 if $prefix
1057 0 0 if $multi_db
1065 0 0 length $fields ? :
1080 0 0 $self->sort ? :
0 0 $self->reverse ? :
1084 0 0 if (length($table_alias = $self->table_alias))
1093 0 0 if ($fields eq $prev_fields and @$queries)
1111 0 0 if @$clauses
1117 0 0 if ($tie and %$tie)
1141 0 0 unless (defined $sth)
1152 0 0 unless (defined wantarray)
1154 0 0 unless $sth->execute
1165 0 0 if (@_)
1183 0 0 if (@_)
1186 0 0 if @_ and @_ % 2
1191 0 0 wantarray ? :
1210 0 0 if @_ == 1 and ref $_[0]
1212 0 0 if (not @arg and $data)
1214 0 0 if ($self->_is_hash($data)) { }
0 0 elsif ($self->_is_array($data)) { }
1224 0 0 if (scalar keys %$constant)
1226 0 0 if $constant->{'sth'} and $self->_is_object($constant->{'sth'}) and $constant->{'sth'}->isa("DB::Object::Statement")
1231 0 0 unless (scalar @arg)
1239 0 0 if scalar @$clauses
1243 0 0 unless $self->where or $self->database_object->allow_bulk_update
1253 0 0 unless (defined wantarray)
1255 0 0 unless $sth->execute
1275 0 0 unless length $self->{$prop} or ref $self->{$prop}
1277 0 0 if (@_) { }
1281 0 0 @_ == 1 && (!$self->_is_object($_[0]) || $self->_is_array($_[0])) && !exists($$fields_ref{"$_[0]"}) ? :
1284 0 0 if ($self->_is_array($data)) { }
1300 0 0 unless length $field
1302 0 0 if exists $fields_ref->{$field}
1303 0 0 if ($self->_is_a($field, 'DB::Object::Fields::Field')) { }
0 0 elsif ($self->_is_a($field, 'DB::Object::Fields::Unknown')) { }
0 0 elsif (ref $field eq 'SCALAR') { }
0 0 elsif ($field =~ /\b(?:$fields)\b/ or $field =~ /\w\([^\)]*\)/ or $field eq '?' or not $bind) { }
1325 0 0 if $prefix
1331 0 0 if $multi_db
1348 0 0 if $bind
1349 0 0 if $bind
1358 0 0 if ($bind)
1385 0 0 if (@_) { }
1387 0 0 @_ == 1 ? :
1388 0 0 if ($self->_is_array($data)) { }
1401 0 0 unless length $field
1403 0 0 if (ref $field eq 'SCALAR') { }
0 0 elsif ($field =~ /\b(?:$fields)\b/ or $field =~ /\w\([^\)]*\)/ or $field eq '?' or not $bind) { }
0 0 elsif ($bind) { }
1415 0 0 if $prefix
1421 0 0 if $multi_db
1449 0 0 if $bind
1450 0 0 if $bind
1459 0 0 if ($bind)
1462 0 0 if $bind and scalar @$ref
1463 0 0 if $bind
1489 0 0 if (not $self->{'limit'} && $self->_is_object($self->{'limit'})) { }
1497 0 0 if (@_) { }
1500 0 0 if (@_ == 1) { }
1514 0 0 unless length $value
1516 0 0 if (ref $value eq 'SCALAR') { }
0 0 elsif ($value eq '?') { }
1540 0 0 if scalar @list
1541 0 0 if scalar @generic
1544 0 0 if (scalar @list)
1546 0 0 if (scalar @list > 1) { }
1548 0 0 if length $list[0]
1549 0 0 if length $list[1]
1554 0 0 if length $list[0]
1571 0 0 if ($type eq "select")
1574 0 0 $self->sort ? :
0 0 $self->reverse ? :
1579 0 0 if $where and $type ne "insert"
1580 0 0 if $group and $type eq "select"
1581 0 0 if $order and $type eq "select"
1582 0 0 if $sort and $order and $type eq "select"
1583 0 0 if $limit and $type ne "insert"
1590 0 0 if ($self->{'query'} and length $self->{'query'})
1601 0 0 unless ($type)
1614 0 0 if ($bind)
1624 0 0 if not $type =~ /^(?:select|delete)$/ and $binded_values->length
1625 0 0 if $where->length and $binded_where->length
1626 0 0 if $group->length and $binded_group->length
1627 0 0 if $order->length and $binded_order->length
1628 0 0 if $limit->length and $binded_limit->length
1631 0 0 if $where->bind->types->length
1632 0 0 if $group->bind->types->length
1633 0 0 if $order->bind->types->length
1634 0 0 if $limit->bind->types->length
1668 0 0 if (not $value =~ /[\r\n]+/ and $value =~ /\b(?:$fields)\b/ || $value =~ /\w\([^\)]*\)/ || $value eq '?') { }
0 0 elsif ($bind) { }
1686 0 0 if $prefix
1693 0 0 if $multi_db
1694 0 0 if @binded
1708 0 0 unless length $self->{$prop} and $self->_is_object($self->{$prop})
1710 0 0 if (@_) { }
1727 0 0 if @_ % 2 and not scalar @_ == 1 && $self->_is_object($_[0])
1730 0 0 if ($self->_is_a($_[0], 'DB::Object::Operator')) { }
1732 0 0 unless $_[0]->isa("DB::Object::Operator")
1742 0 0 if @arg
1748 0 0 if (ref $data eq 'SCALAR') { }
0 0 elsif (ref $data) { }
0 0 elsif ($data) { }
1758 0 0 if ($self->_is_object($arg[0]) and $arg[0]->isa('DB::Object::Operator')) { }
0 0 elsif ($self->_is_object($arg[0]) and $arg[0]->isa('DB::Object::Query::Clause')) { }
0 0 elsif ($self->_is_a($arg[0], 'DB::Object::Expression')) { }
0 0 elsif ($self->_is_object($arg[0]) and $arg[0]->isa('DB::Object::Fields::Field::Overloaded')) { }
0 0 elsif ($self->_is_a($arg[0], 'DB::Object::Fields::Unknown')) { }
0 0 elsif (scalar(@arg) % 2 and not ref $arg[0]) { }
0 0 elsif (scalar(@arg) % 2 and ref $arg[0] eq 'SCALAR') { }
0 0 elsif ($self->_is_a($arg[0], 'DB::Object::Fields::Field') and scalar @arg == 1) { }
1785 0 0 if ($f->binded)
1788 0 0 if ($const) { }
1801 0 0 if (scalar @arg and $self->_is_a($arg[0], "DB::Object::Fields::Field"))
1834 0 0 if ($self->_is_a($field, "DB::Object::Fields::Field") and $self->_is_a($value, "DB::Object::Fields::Field::Overloaded"))
1840 0 0 unless ($self->_is_a($field, "DB::Object::Fields::Field"))
1842 0 0 if $prefix
1845 0 0 if ($self->_is_a($value, 'DB::Object::NOT')) { }
0 0 elsif (not defined $value or lc $value eq 'null') { }
1848 0 0 unless defined $value
1850 0 0 if (lc $value eq "null")
1874 0 0 if ($self->_is_a($field, 'DB::Object::Fields::Field')) { }
1880 0 0 $prefix ? :
1883 0 0 if (ref $value eq 'SCALAR') { }
0 0 elsif (ref $value eq "${base_class}::Statement") { }
0 0 elsif (ref $value eq 'Regexp') { }
0 0 elsif ($value =~ /[\s\(\)\.\'\"]+(?:$fields)[\s\(\)\.\'\"]+/ or $value =~ /\w\([^\)]*\)/ or $value eq '?') { }
1885 0 0 $i_am_negative ? :
1898 0 0 $i_am_negative ? :
0 0 $i_am_negative ? :
1905 0 0 if $self->_is_a($field, "DB::Object::Fields::Field")
1911 0 0 if ($value =~ s/^\(\?\^\://)
1916 0 0 if ($self->database_object->driver eq 'Pg') { }
0 0 elsif ($self->database_object->driver eq 'SQLite' or $self->database_object->driver eq 'mysql') { }
1918 0 0 $i_am_negative ? :
0 0 $i_am_negative ? :
1927 0 0 $i_am_negative ? :
0 0 $i_am_negative ? :
1935 0 0 if $self->_is_a($field, "DB::Object::Fields::Field")
1943 0 0 $i_am_negative ? :
1947 0 0 if $value eq "?"
1948 0 0 if $self->_is_a($field, "DB::Object::Fields::Field")
1955 0 0 if (lc $fields_type->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
1957 0 0 $i_am_negative ? :
1965 0 0 $i_am_negative ? :
0 0 $i_am_negative ? :
1972 0 0 if $self->_is_a($field, "DB::Object::Fields::Field")
1973 0 0 if (lc $fields_type->{$field} eq 'bytea' and $const = $self->database_object->get_sql_type('bytea')) { }
1982 0 0 if $value eq "?"
1992 0 0 if $bind
2039 0 0 unless defined $self->SUPER::init(@copy)
2049 0 0 if ($self->generic->length and $self->query_object->table_object->use_bind)
2051 0 0 unless $fields->length
2055 0 0 unless $fields->length
2083 0 0 if (@_)
2091 0 0 if ($self->_is_object($_[0]) and $_[0]->isa('DB::Object::Operator')) { }
2094 0 0 if $op_obj->operator ne "AND" and $op_obj->operator ne "OR" and $op_obj->operator ne "NOT"
2104 0 0 if $self->value->length > 0
2106 0 0 if $self->generic->length > 0
2111 0 0 if ($self->_is_a($this, ["DB::Object::Fields::Field::Overloaded", "DB::Object::Expression"]))
2117 0 0 unless $self->_is_a($this, "DB::Object::Query::Clause")
2119 0 0 unless ($this->value->length)
2123 0 0 if ($self->type->length and $this->type->length and $this->type ne $self->type)
2134 0 0 unless $self->type->length
2136 0 0 if $this->generic->length
2137 0 0 if $this->fields->length
2138 0 0 if $this->bind->types->length
2139 0 0 if $this->bind->values->length
2144 0 0 unless exists $hash->{$k}