File Coverage

blib/lib/DBIx/Simple/Interpol.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 34 35 97.1


line stmt bran cond sub pod time code
1 1     1   469 use 5.006; use strict; use warnings;
  1     1   3  
  1     1   4  
  1         1  
  1         16  
  1         4  
  1         1  
  1         34  
2              
3             package DBIx::Simple::Interpol;
4              
5             our $VERSION = '1.007';
6              
7 1     1   897 use SQL::Interpol ();
  1         3176  
  1         17  
8 1     1   662 use DBIx::Simple ();
  1         9  
  1         115  
9              
10             sub import {
11 1     1   746 shift;
12 1         6 my $prelude = sprintf qq'package %s;\n#line %d "%s"\n', ( caller )[0,2,1];
13 1         44 my $sub = eval qq{ sub { $prelude SQL::Interpol->import(\@_) } };
14 1         10 &$sub;
15             }
16              
17             sub iquery {
18 1     1 0 831 my $self = shift;
19 1         5 my $p = SQL::Interpol::Parser->new;
20 1         13 my $sql = $p->parse( @_ );
21 1         135 $self->query( $sql, @{ $p->bind } );
  1         15  
22             }
23              
24             die 'Cannot find method to patch' if not DBIx::Simple->can( 'iquery' );
25              
26 1     1   6 do { no warnings 'redefine'; *DBIx::Simple::iquery = \&iquery };
  1         1  
  1         55  
27              
28             __END__