File Coverage

blib/lib/SQL/Maker/Plugin/InsertOnDuplicate.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package SQL::Maker::Plugin::InsertOnDuplicate;
2 1     1   640 use strict;
  1         1  
  1         38  
3 1     1   4 use warnings;
  1         2  
  1         26  
4 1     1   4 use utf8;
  1         1  
  1         6  
5              
6             our @EXPORT = qw/insert_on_duplicate/;
7              
8             sub insert_on_duplicate {
9 1     1 1 76 my ( $self, $table_name, $insert_values, $update_values ) = @_;
10 1         8 my ( $sql, @binds ) = $self->insert( $table_name, $insert_values );
11 1         4 my ( $update_cols, $update_vals ) = $self->make_set_clause($update_values);
12 1         3 $sql .= $self->new_line . "ON DUPLICATE KEY UPDATE " . join( ', ', @$update_cols );
13 1         10 return ( $sql, @binds, @$update_vals );
14             }
15              
16             1;
17             __END__