Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (32 sloc) 1 KB
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Test::Most;
use testlib;
use DBI;
use DBD::Pg;
use Path::Class qw(file dir);
use Time::HiRes qw(time);
my $tsv = testlib->tsv;
my $dbh = testlib->dbh;
cmp_ok(testlib->truncate_all(), '==', 0, 'table truncate');
testlib->insert_or_update_row(\&insert_or_update);
testlib->table_dump_file->spew(testlib->dump_pg_n_pl_bulking_table);
done_testing();
sub insert_or_update {
my ($row_data) = @_;
return unless $row_data;
my @bind_params = @$row_data{qw(title num meta ident)};
state $sth_u = $dbh->prepare('UPDATE pg_n_pl_bulking SET title=?,num=?,meta=? WHERE ident=?');
state $sth_i = $dbh->prepare('INSERT INTO pg_n_pl_bulking (title,num,meta,ident) VALUES (?,?,?,?)');
my $updated = $sth_u->execute(@bind_params);
$sth_i->execute(@bind_params)
if $updated == 0;
}
__END__
=head1 NAME
03.1_insert-data_standard.t - do basic update and inserts statements
=head1 SYNOPSIS
prove -l -v t/03_insert-data_standard.t
=cut
You can’t perform that action at this time.