add a prototype fix for not having InnoDB tables causing test errors
This commit is contained in:
parent
f3b7b1bf8e
commit
57ff4405a6
1 changed files with 43 additions and 36 deletions
79
t/SQL.t
79
t/SQL.t
|
|
@ -154,57 +154,64 @@ ok( !$session->db->dbh->{AutoCommit}, 'AutoCommit disabled, transaction started.
|
||||||
$session->db->rollback;
|
$session->db->rollback;
|
||||||
ok( $session->db->dbh->{AutoCommit}, 'AutoCommits reenabled, aborted transaction finished');
|
ok( $session->db->dbh->{AutoCommit}, 'AutoCommits reenabled, aborted transaction finished');
|
||||||
|
|
||||||
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
|
my %mysqlVariables = $session->db->quickArray("SHOW GLOBAL VARIABLES where Variable_name='have_innodb'");
|
||||||
$session->db->dbh->do('CREATE TABLE testTable (myIndex int(8) NOT NULL default 0, message varchar(64), PRIMARY KEY(myIndex)) TYPE=InnoDB');
|
|
||||||
|
|
||||||
my $dbh2 = WebGUI::SQL->connect($session,$session->config->get("dsn"), $session->config->get("dbuser"), $session->config->get("dbpass"));
|
SKIP: {
|
||||||
my ($sth, $sth2, $rc);
|
|
||||||
|
|
||||||
$sth = $session->db->prepare('select myIndex from testTable');
|
skip("No InnoDB tables in this MySQL. Skipping all transaction related tests.",7) if (lc $mysqlVariables{have_innodb} ne 'yes');
|
||||||
$sth2 = $dbh2->prepare('select myIndex from testTable');
|
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
|
||||||
|
$session->db->dbh->do('CREATE TABLE testTable (myIndex int(8) NOT NULL default 0, message varchar(64), PRIMARY KEY(myIndex)) TYPE=InnoDB');
|
||||||
|
|
||||||
#rollback test
|
my $dbh2 = WebGUI::SQL->connect($session,$session->config->get("dsn"), $session->config->get("dbuser"), $session->config->get("dbpass"));
|
||||||
|
my ($sth, $sth2, $rc);
|
||||||
|
|
||||||
$rc = $session->db->beginTransaction();
|
$sth = $session->db->prepare('select myIndex from testTable');
|
||||||
ok( $rc, 'beginTransaction returned successfully');
|
$sth2 = $dbh2->prepare('select myIndex from testTable');
|
||||||
ok( !$session->db->dbh->{AutoCommit}, 'AutoCommit disabled, new transaction started');
|
|
||||||
|
|
||||||
$session->db->dbh->do("INSERT INTO testTable VALUES(0,'zero')");
|
#rollback test
|
||||||
$session->db->dbh->do("INSERT INTO testTable VALUES(1,'one')");
|
|
||||||
$session->db->dbh->do("INSERT INTO testTable VALUES(2,'two')");
|
|
||||||
|
|
||||||
$sth2->execute;
|
$rc = $session->db->beginTransaction();
|
||||||
is( $sth2->rows, 0, 'access from second dbh on uncommitted data');
|
ok( $rc, 'beginTransaction returned successfully');
|
||||||
$sth2->finish;
|
ok( !$session->db->dbh->{AutoCommit}, 'AutoCommit disabled, new transaction started');
|
||||||
|
|
||||||
$session->db->rollback;
|
$session->db->dbh->do("INSERT INTO testTable VALUES(0,'zero')");
|
||||||
|
$session->db->dbh->do("INSERT INTO testTable VALUES(1,'one')");
|
||||||
|
$session->db->dbh->do("INSERT INTO testTable VALUES(2,'two')");
|
||||||
|
|
||||||
$sth->execute;
|
$sth2->execute;
|
||||||
is( $sth->rows, 0, 'rollback called, no updates to table');
|
is( $sth2->rows, 0, 'access from second dbh on uncommitted data');
|
||||||
$sth->finish;
|
$sth2->finish;
|
||||||
|
|
||||||
$session->db->beginTransaction();
|
$session->db->rollback;
|
||||||
$rc = $session->db->dbh->do("INSERT INTO testTable VALUES(0,'zero')");
|
|
||||||
$session->db->dbh->do("INSERT INTO testTable VALUES(1,'one')");
|
|
||||||
$session->db->dbh->do("INSERT INTO testTable VALUES(2,'two')");
|
|
||||||
|
|
||||||
$sth2->execute;
|
$sth->execute;
|
||||||
is( $sth2->rows, 0, 'access from second dbh on uncommitted data');
|
is( $sth->rows, 0, 'rollback called, no updates to table');
|
||||||
$sth2->finish;
|
$sth->finish;
|
||||||
|
|
||||||
$session->db->commit;
|
$session->db->beginTransaction();
|
||||||
|
$rc = $session->db->dbh->do("INSERT INTO testTable VALUES(0,'zero')");
|
||||||
|
$session->db->dbh->do("INSERT INTO testTable VALUES(1,'one')");
|
||||||
|
$session->db->dbh->do("INSERT INTO testTable VALUES(2,'two')");
|
||||||
|
|
||||||
$sth->execute;
|
$sth2->execute;
|
||||||
is( $sth->rows, 3, 'rows inserted, committed');
|
is( $sth2->rows, 0, 'access from second dbh on uncommitted data');
|
||||||
$sth->finish;
|
$sth2->finish;
|
||||||
|
|
||||||
$sth2->execute;
|
$session->db->commit;
|
||||||
is( $sth2->rows, 3, 'access from second dbh on committed data');
|
|
||||||
$sth2->finish;
|
|
||||||
|
|
||||||
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
|
$sth->execute;
|
||||||
|
is( $sth->rows, 3, 'rows inserted, committed');
|
||||||
|
$sth->finish;
|
||||||
|
|
||||||
$session->db->dbh->do('CREATE TABLE testTable (myIndex int(8) NOT NULL default 0, message varchar(64), myKey varchar(32), PRIMARY KEY(myIndex)) TYPE=InnoDB');
|
$sth2->execute;
|
||||||
|
is( $sth2->rows, 3, 'access from second dbh on committed data');
|
||||||
|
$sth2->finish;
|
||||||
|
|
||||||
|
$session->db->dbh->do('DROP TABLE IF EXISTS testTable');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->db->dbh->do('CREATE TABLE testTable (myIndex int(8) NOT NULL default 0, message varchar(64), myKey varchar(32), PRIMARY KEY(myIndex))');
|
||||||
|
|
||||||
my @tableData = (
|
my @tableData = (
|
||||||
[ 0, 'zero', 'A' ],
|
[ 0, 'zero', 'A' ],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue