File Coverage

blib/lib/DBIx/DBO/DBD/SQLite.pm
Criterion Covered Total %
statement 26 26 100.0
branch 7 10 70.0
condition 2 6 33.3
subroutine 8 8 100.0
pod n/a
total 43 50 86.0


line stmt bran cond sub pod time code
1 1     1   22 use 5.014;
  1         4  
2 1     1   9 use warnings;
  1         2  
  1         85  
3 1     1   9 use DBD::SQLite 1.31;
  1         39  
  1         50  
4              
5 1 50   1   51 BEGIN { die 'DBD::SQLite version 1.31 required (but not version 1.38_01)' if $DBD::SQLite::VERSION eq '1.38_01' }
6              
7             package # hide from PAUSE
8             DBIx::DBO::DBD::SQLite;
9 1     1   7 use Carp 'croak';
  1         2  
  1         603  
10              
11             sub _get_table_schema {
12 9     9   71 my($class, $me, $table) = @_;
13              
14 9         141 my $q_table = $table =~ s/([\\_%])/\\$1/gr;
15              
16             # Try just these types
17 9         39 my $info = $me->rdbh->table_info(undef, undef, $q_table,
18             'TABLE,VIEW,GLOBAL TEMPORARY,LOCAL TEMPORARY,SYSTEM TABLE', {Escape => '\\'})->fetchall_arrayref;
19 9 50 33     13859 croak 'Invalid table: '.$class->_qi($me, $table) unless $info and @$info == 1 and $info->[0][2] eq $table;
      33        
20 9         116 return $info->[0][1];
21             }
22              
23             sub _save_last_insert_id {
24 7     7   24 my($class, $me, $sth) = @_;
25 7         132 $sth->{Database}->last_insert_id(undef, @$me{qw(Schema Name)}, undef);
26             }
27              
28             sub _build_limit {
29 75     75   172 my($class, $me) = @_;
30 75         240 my $h = $me->_build_data;
31 75 100       323 return '' unless defined $h->{limit};
32 15         29 my $sql = 'LIMIT ';
33 15 50       64 $sql .= $h->{limit}[0] >= 0 ? $h->{limit}[0] : -1;
34 15 100       50 $sql .= ' OFFSET '.$h->{limit}[1] if $h->{limit}[1];
35 15         58 return $sql;
36             }
37              
38             1;