Branch Coverage

lib/UR/DataSource/SQLite.pm
Criterion Covered Total %
branch 125 238 52.5


line true false branch
75 2 173 if ($self->_db_path_specifies_a_directory($self->server)) { }
88 0 2 unless -f $main_schema_file or UR::Util::touch_file($main_schema_file)
114 2 2 if $file eq $main_db_file
118 0 2 unless $dbh->do("ATTACH DATABASE '${pathname}' as $schema")
131 4 4 unless -f $pathname
132 4 0 if $self->_schema_from_schema_filename($name)
141 6 0 $ext ? :
146 0 0 if -e $self->server
147 0 0 if -e $self->_data_dump_path
153 0 0 if $self->database_exists
155 0 0 if 'IO::File'->new(">$path")
175 0 579 unless $path =~ s/\.pm$/$ext/
203 0 44 if ($schema_time and -e $db_file && $schema_time > $db_time || -e $dump_file && $schema_time > $dump_time)
207 0 0 if -e $dbbak_file
208 0 0 if -e $dumpbak_file
209 0 0 if -e $db_file
210 0 0 if -e $dump_file
211 0 0 if (-e $db_file)
214 0 0 if (-e $dump_file)
218 137 39 if (-e $db_file)
219 0 137 if ($dump_time and $db_time < $dump_time)
222 0 0 if -e $bak_file
224 0 0 if (-e $db_file)
231 39 137 unless (-e $db_file)
237 39 0 if (-e $dump_file) { }
0 0 elsif (not -e $db_file and -e $schema_file) { }
0 0 elsif ($self->class ne 'UR::DataSource::SQLite') { }
241 0 39 unless (-e $db_file)
249 0 0 unless (-e $db_file)
258 0 0 unless (-e $template_database_file)
261 0 0 unless (File::Copy::copy($template_database_file, $db_file))
264 0 0 unless (-e $db_file)
279 0 172 unless defined $dbh
289 0 2 if $table_name =~ /^(sqlite|\$|URMETA)/
301 22 2 unless ($self->{'_has_sequence_generator'}{$seq_table} or grep {$_ eq $seq_table;} $self->get_table_names)
303 0 22 unless ($dbh->do("CREATE TABLE IF NOT EXISTS $seq_table (next_value integer PRIMARY KEY AUTOINCREMENT)"))
318 3 91 unless ($dbh->do("INSERT into $sequence_name values(null)"))
323 0 91 unless (defined $new_id)
327 0 91 unless ($dbh->do("DELETE from $sequence_name where next_value = $new_id"))
351 29 0 if ($sqlite_version >= $needed_version or not $sth)
361 0 0 unless (@returned_names)
369 0 0 unless my $sponge = 'DBI'->connect('DBI:Sponge:', '', '')
372 0 0 unless (@returned_names)
376 0 0 unless my $returned_sth = $sponge->prepare("table_info $table_name", {'rows', [map({[@{$_;}{@returned_names}];} @tables)], 'NUM_OF_FIELDS', scalar @returned_names, 'NAME', \@returned_names})
392 0 29 unless defined $column
401 0 29 if ($DBD::SQLite::VERSION < 1.2604)
408 0 29 unless my $sth = $dbh->prepare("PRAGMA table_info($table_name)")
410 0 29 unless $sth->execute
414 0 68 unless $info->{'name'} =~ /$column_regex/
419 1 67 if ($data_type =~ /(\S+)\s*\((\S+)\)/)
433 52 16 $node->{'NULLABLE'} ? :
441 1 67 if defined $node->{'COLUMN_DEF'}
447 0 29 unless my $sponge = 'DBI'->connect('DBI:Sponge:', '', '')
454 0 29 unless my $returned_sth = $sponge->prepare("column_info $table", {'rows', [map({[@{$_;}{@returned_names}];} @columns)], 'NUM_OF_FIELDS', scalar @returned_names, 'NAME', \@returned_names})
469 0 43 if (@$column_list != @$r_column_list)
474 0 43 unless $table_info
479 43 0 if ($col_str =~ /^CREATE TABLE (\w+)\s*?\((.*?)\)$/is) { }
480 0 43 unless ($1 eq $table_name)
490 10 33 if (@$column_list > 1) { }
500 8 2 if ($col_str =~ /$regex/) { }
512 8 25 if ($col_str =~ /FOREIGN KEY\s*\($col\)\s*REFERENCES $r_table_name\s*\($r_col\)/i) { }
519 43 15 if ($col_str =~ /^(.*?)\s*,\s*(.*)/) { }
528 35 23 unless $col_name and $col_name eq $col
531 23 0 if ($this_col =~ /REFERENCES $r_table_name\s*\($r_col\)/i) { }
558 50 38 if ($fk_table) { }
38 0 elsif ($pk_table) { }
576 0 88 unless my $sponge = 'DBI'->connect('DBI:Sponge:', '', '')
584 0 88 unless my $returned_sth = $sponge->prepare("foreign_key_info $table", {'rows', [map({[@{$_;}{@returned_names}];} @returned_fk_info)], 'NUM_OF_FIELDS', scalar @returned_names, 'NAME', \@returned_names})
610 0 276 unless my $fksth = $dbh->prepare("PRAGMA foreign_key_list($fk_table_name)")
612 0 276 unless ($fksth->execute)
620 198 53 unless &$accept_rows($row)
638 43 233 if (@fk_rows_this_table)
661 0 30 unless $dbh
664 11 19 if ($owner_name)
671 0 30 unless $idx_sth
677 0 10 unless $data->{'unique'}
707 0 115 unless $worked
712 77 38 if $has_no_pending_trans
714 38 0 unless $self->dump_on_commit or -e $dump_filename
732 45 38 if ($name)
737 81 2 if ($type)
742 10 73 $schema ? :
746 83 0 if (@where)
752 0 83 unless ($sth)
758 0 83 unless ($sth->execute(@exec_values))
789 0 39 unless ($fh)
794 0 39 if (-f $db_file)
795 0 0 unless (unlink $db_file)
801 0 39 unless ($dbh)
810 39 788 unless $sql =~ /\S/
811 78 710 if $sql =~ /BEGIN TRANSACTION|COMMIT/i
814 30 680 if ($sql =~ /PRAGMA foreign_keys\s*=\s*(\w+)/)
817 0 30 unless (defined $fk_setting)
823 0 0 if ($value ne 'OFF')
830 0 710 unless ($dbh->do($sql))
848 0 0 if (@_)
862 30 2 unless (exists $foreign_key_setting{$id})
876 7 2154 if ($is_optional) { }
3 2151 elsif ($query_plan->order_by_column_is_descending($column_name)) { }
877 3 4 if ($query_plan->order_by_column_is_descending($column_name)) { }
891 1 1421 !defined($limit) && $query_plan->offset ? :
903 0 1 unless (-w $file_name)
909 0 1 unless ($fh)
915 0 1 unless ($dbh)
919 1 0 if (defined $fk_setting) { }
921 0 1 $fk_setting ? :
925 0 0 if (defined $fk_setting)
937 2 0 unless substr($creation_sql, -1, 1) eq ';'
938 2 0 unless substr($creation_sql, -1, 1) eq "\n"
942 2 0 if ($item_info->{'type'} eq 'table')
944 0 2 unless ($sth)
947 0 2 unless ($sth->execute)
953 1 11 if (not defined $col) { }
2 9 elsif ($col =~ /\D/ or length $col == 0) { }
979 0 70 unless $db_file
982 36 34 if ($self->_db_path_specifies_a_directory($db_file))
1004 0 90 if ($schema_name and not $self->is_schema_attached($schema_name, $dbh))
1013 0 0 unless (UR::Util::touch_file($schema_filename))
1017 0 0 unless ($dbh->do("ATTACH DATABASE '${schema_filename}' as $schema_name"))