Skinny/DBD/mysql.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 38 CC 2 SCAR 12.0
CC
2
Cov
0%
bulk_insert
6.0
sql_for_unixtime
2.0
BEGIN
2.0
CRAP 3.3
1 package DBIx::Skinny::DBD::mysql;
2 use strict;
3 use warnings;
4 use base 'DBIx::Skinny::DBD::Base';
5  
6 sub sql_for_unixtime { "UNIX_TIMESTAMP()" }
7  
8 sub bulk_insert {
9 my ($skinny, $table, $args) = @_;
10  
11 return unless @$args;
12  
13 my (@cols, @bind);
14  
15 # setting cols
16 my ($first_arg,) = @{$args};
17 for my $col (keys %{$first_arg}) {
18 push @cols, $col;
19 }
20
21 for my $arg (@{$args}) {
22 # deflate
23 for my $col (@cols) {
24 $arg->{$col} = $skinny->schema->call_deflate($col, $arg->{$col});
25 push @bind, $skinny->schema->utf8_off($col, $arg->{$col});
26 }
27 }
28  
29 my $sql = "INSERT INTO $table\n";
30 $sql .= '(' . join(', ', @cols) . ')' . "\nVALUES ";
31  
32 my $values = '(' . join(', ', ('?') x @cols) . ')' . "\n";
33 $sql .= join(',', ($values) x (scalar(@bind) / scalar(@cols)));
34  
35 $skinny->_execute($sql, \@bind);
36  
37 return 1;
38 }
39  
40 1;
41