blib/lib/DBIx/Changeset/Loader/Mysql.pm

filter: Statementstmt 65.7% 23 / 35 Branchbran 25.0% 4 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 58.5% 41 / 70 CC 10 SCAR 32.7
CC
10
Cov
50%
apply_changeset
48.9
BEGIN
1.0
BEGIN
1.0
CRAP 26.2
« blib/lib/DBIx/Changeset/Loader/Pg.pm ↑ Summary blib/lib/DBIx/Changeset/App/Command/applied.pm »
1 package DBIx::Changeset::Loader::Mysql;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use base qw/DBIx::Changeset::Loader/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use vars qw{$VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '1.11';
12 }
13  
14 =head1 NAME
15  
16 DBIx::Changeset::Loader::Mysql - Mysql factory object for loading changesets into a mysql database
17  
18 =head1 SYNOPSIS
19  
20 Perhaps a little code snippet.
21  
22 use DBIx::Changeset::Loader;
23  
24 my $foo = DBIx::Changeset::Loader->new('Mysql', $opts);
25 ...
26 $foo->apply_changeset($record);
27  
28 =head1 METHODS
29  
30 =head2 start_transaction
31 This is the start_transaction interface to implement in your own class
32 =cut
33 1 ▶sub start_transaction {
Subroutine start_transaction: called CC=1 SCAR=0.0
Pod documented
34 }
35  
36 =head2 commit_transaction
37 This is the commit_transaction interface to implement in your own class
38 =cut
39 1 ▶sub commit_transaction {
Subroutine commit_transaction: called CC=1 SCAR=0.0
Pod documented
40 }
41  
42 =head2 rollback_transaction
43 This is the rollback_transaction interface to implement in your own class
44 =cut
45 1 ▶sub rollback_transaction {
Subroutine rollback_transaction: called CC=1 SCAR=0.0
Pod documented
46 }
47  
48 =head2 apply_changeset
49 This is the apply_changeset interface to implement in your own class
50 =cut
51 4 ▶sub apply_changeset {
Subroutine apply_changeset: called CC=10 SCAR=38.9
Pod documented
52 4 my ($self, $record) = @_;
53  
54 4 ▶ unless ( defined $record ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'Missing a DBIx::Changeset::Record'); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $record) 2 2 4
55 0 ▶ unless ( $record->valid() ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'Passed an Invalid DBIx::Changeset::Record'); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($record->valid) 0 2 2
56 2 ▶ unless ( defined $self->db_name ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'need a db_name parameter'); }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->db_name) 2 0 2
57
58 0 my $perms = "";
59 0 ▶ $perms = "-u".$self->db_user() if ($self->db_user);
Branch: 1 branch
BranchTrueFalseTotal
if $self->db_user 0 0 0
60 0 ▶ $perms .= " -p".$self->db_pass() if ($self->db_pass);
Branch: 1 branch
BranchTrueFalseTotal
if $self->db_pass 0 0 0
61 0 ▶ $perms .= " -h".$self->db_host() if ($self->db_host);
Branch: 1 branch
BranchTrueFalseTotal
if $self->db_host 0 0 0
62  
63 0 my $DB = "";
64 0 ▶ $DB = $self->db_name if ($self->db_name);
Branch: 1 branch
BranchTrueFalseTotal
if $self->db_name 0 0 0
65  
66 0 my $sql = File::Spec->catfile($record->changeset_location, $record->uri);
67
68 0 my $result = qx/mysql $perms $DB < $sql 2>&1/;
69 0 ▶ if ($? or ($result =~ m#ERROR#xmgs)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? or $result =~ /ERROR/gmsx) 0 0 0
Condition0%0/3
$? or $result =~ /ERROR/gmsx
l!l&&r!l&&!r
000
MC/DC0%0/2
$? or $result =~ /ERROR/gmsx
$? $result =~ /ERROR/gmsx
Truth table0%0/3
A or B
A= $?B= $result =~ /ERROR/gmsx
ABresult
1X1
011
000
70 0 DBIx::Changeset::Exception::LoaderException->throw(error => $result);
71 }
72  
73 0 return;
74 }
75  
76 =head1 COPYRIGHT & LICENSE
77  
78 Copyright 2004-2008 Grox Pty Ltd.
79  
80 This program is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82  
83 The full text of the license can be found in the LICENSE file included with this module.
84  
85 =cut
86  
87 2 1; # End of DBIx::Changeset
« blib/lib/DBIx/Changeset/Loader/Pg.pm ↑ Summary blib/lib/DBIx/Changeset/App/Command/applied.pm »