Branch Coverage

lib/Mail/DMARC/Report/Store/SQL.pm
Criterion Covered Total %
branch 107 182 58.7


line true false branch
23 0 5 if "Mail::DMARC::Policy" ne ref $agg->policy_published
28 0 20 unless $agg->metadata->$f
31 0 5 unless my $rid = $self->get_report_id($agg)
35 0 5 unless ($agg->record)
53 1 5 if ($args{'rid'})
57 1 5 if ($args{'begin'})
61 1 5 if ($args{'end'})
65 1 5 if ($args{'author'})
69 1 5 if ($args{'from_domain'})
86 4 4 unless (exists $self->{'_todo_list'})
88 0 4 unless $self->{'_todo_list'}
92 4 4 unless ($next_todo)
115 0 1 unless scalar @$reports
134 0 8 unless my $report_id = shift()
135 0 8 if $self->verbose
141 4 4 if (scalar @row_ids)
143 0 12 if $self->verbose
149 0 24 if $self->verbose
161 0 48 unless $domain
163 27 21 if ($r and scalar @$r)
171 0 12 unless $meta->org_name
176 3 9 if ($r and scalar @$r)
179 0 9 unless $meta->email
193 0 9 unless my $author_id = $self->get_author_id($meta)
194 0 9 unless my $from_dom_id = $self->get_domain_id($pol->domain)
197 0 9 if ($meta->report_id) { }
213 0 9 if (scalar @$ids)
217 0 9 unless my $rid = $self->{'report_id'} = $self->query($self->grammar->insert_report, [$from_dom_id, $meta->begin, $meta->end, $author_id, $meta->uuid])
228 0 4 if @args % 2
237 0 4 if ($args{'searchField'} and $known{$args{'searchField'}})
243 20 0 unless defined $args{$known}
247 0 4 if ($args{'sidx'} and $known{$args{'sidx'}})
248 0 0 if ($args{'sord'})
249 0 0 $args{'sord'} eq 'desc' ? :
254 1 3 if ($args{'rows'})
255 0 1 if ($args{'page'}) { }
258 0 0 if $start < 0
293 0 0 if @args % 2
296 0 0 unless defined $args{'rid'}
300 0 0 if $self->grammar->language ne "postgresql"
341 6 0 if $self->grammar->language ne "postgresql"
359 0 12 unless my $type = $reason->{'type'}
373 0 6 $self->grammar->language eq 'postgresql' ? :
2 4 $reasons{$u} ? :
385 5 0 unless (defined $rec->{'row'}{'count'})
386 0 5 if $self->verbose
395 0 0 if scalar @$rows
402 0 5 if $self->row_exists($row_id, $rec)
404 0 5 unless $row_id = $self->insert_rr($row_id, $rec)
408 5 0 if ($reasons)
410 0 2 unless $reason and $reason->{'type'}
416 5 0 if ($spf_ref)
423 5 0 if ($dkim)
425 0 5 unless $sig and $sig->{'domain'}
455 2 30 unless defined $dkim->{$_}
456 8 22 if ("domain" eq $_)
473 0 39 unless defined $spf->{$_}
474 13 26 if ("domain" eq $_)
489 0 6 unless $report_id
493 6 0 if $self->grammar->language ne "postgresql"
499 18 0 $rec->identifiers->$f ? :
503 0 6 unless my $rr_id = $self->query($query, \@args)
519 0 631 unless my $dsn = $self->config->{'report_store'}{'dsn'}
524 621 0 if ($self->{'grammar'} and $self->{'dbix'})
526 621 0 if ($dsn =~ /$cached_grammar_type/)
534 10 0 if ($dsn =~ /sqlite/i) { }
0 0 elsif ($dsn =~ /mysql/i) { }
0 0 elsif ($dsn =~ /pg/i) { }
536 6 4 if (not $db or $db eq ":memory:" or not -e $db)
538 0 6 unless $needs_tables = $self->get_db_schema($schema)
551 0 10 unless $self->{'dbix'} = "DBIx::Simple"->connect($dsn, $user, $pass)
554 6 4 if ($needs_tables)
564 269 1 unless defined $DBI::errstr
565 0 1 unless $DBI::errstr
566 0 1 if $DBI::errstr eq "DBI error: "
570 722 0 if $_[0]{'dbix'}
584 6 0 if -f "share/$file"
596 282 8 if (defined $params)
597 282 0 ref $params eq 'ARRAY' ? :
602 0 290 if @extra
604 0 290 unless my $dbix = $self->db_connect
606 94 196 if $query =~ /^INSERT/xi
607 2 194 if $query =~ /^(?:REPLACE|UPDATE)/xi
608 49 145 if $query =~ /^(?:DELETE|TRUNCATE)/xi
616 1 144 unless eval { do { $r = $self->dbix->query($query, @params)->hashes } }
618 0 144 unless $r
624 2 92 unless (eval { do { $self->dbix->query($query, @params) } })
632 0 92 if $table =~ /\(/
634 0 92 unless $table
640 0 1 unless $self->dbix->query($query, @params)
647 16 32 unless my $affected = $self->dbix->query($query, @params)->rows