diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-09-24 10:15:50 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:46 +0000 |
commit | 485b97be9f2f2abf5a40923b5fd85f75714a8c02 (patch) | |
tree | ca05cb0ecf3828d909a898c3e5805804a0aff5f8 /t/06_tran.t | |
download | perl-dbd-sqlite-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz.HEADDBD-SQLite-1.38_01masterbaserock/morph
Diffstat (limited to 't/06_tran.t')
-rw-r--r-- | t/06_tran.t | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/t/06_tran.t b/t/06_tran.t new file mode 100644 index 0000000..c3c9bc1 --- /dev/null +++ b/t/06_tran.t @@ -0,0 +1,55 @@ +#!/usr/bin/perl + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test; +use Test::More tests => 6; +use Test::NoWarnings; + +my $dbh = connect_ok( + AutoCommit => 0, + RaiseError => 1, +); + +ok $dbh->{sqlite_use_immediate_transaction}, "sqlite_use_immediate_transaction is true by default"; + +$dbh->do("CREATE TABLE MST (id, lbl)"); +$dbh->do("CREATE TABLE TRN (no, id, qty)"); + +$dbh->commit; +$dbh->do("INSERT INTO MST VALUES(1, 'ITEM1')"); +$dbh->do("INSERT INTO MST VALUES(2, 'ITEM2')"); +$dbh->do("INSERT INTO MST VALUES(3, 'ITEM3')"); +$dbh->do("INSERT INTO TRN VALUES('A', 1, 5)"); +$dbh->do("INSERT INTO TRN VALUES('B', 2, 2)"); +$dbh->do("INSERT INTO TRN VALUES('C', 1, 4)"); +$dbh->do("INSERT INTO TRN VALUES('D', 3, 3)"); +$dbh->rollback; + +my $sth = $dbh->prepare( +"SELECT TRN.id AS ID, MST.LBL AS TITLE, + SUM(qty) AS TOTAL FROM TRN,MST +WHERE TRN.ID = MST.ID +GROUP BY TRN.ID ORDER BY TRN.ID DESC"); +my $rows = $sth->execute(); +ok($rows, "0E0"); +my $names = $sth->{NAME}; +print(join(', ', @$names), "\n"); +while(my $raD = $sth->fetchrow_arrayref()) { + print join(":", @$raD), "\n"; +} + +$dbh->rollback; + +{ + my $dbh = connect_ok( + AutoCommit => 0, + RaiseError => 1, + sqlite_use_immediate_transaction => 0, + ); + ok !$dbh->{sqlite_use_immediate_transaction}, "sqlite_use_immediate_transaction is false if you set explicitly"; +} |