[Bast-commits] r7846 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage/DBI/Sybase t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Fri Nov 6 15:01:30 GMT 2009
Author: caelum
Date: 2009-11-06 15:01:30 +0000 (Fri, 06 Nov 2009)
New Revision: 7846
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm
DBIx-Class/0.08/trunk/t/74mssql.t
Log:
transactions for MSSQL over DBD::Sybase
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm 2009-11-04 10:00:17 UTC (rev 7845)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm 2009-11-06 15:01:30 UTC (rev 7846)
@@ -29,6 +29,24 @@
$self->set_textsize;
}
+sub _dbh_begin_work {
+ my $self = shift;
+
+ $self->_get_dbh->do('BEGIN TRAN');
+}
+
+sub _dbh_commit {
+ my $self = shift;
+
+ $self->_dbh->do('COMMIT');
+}
+
+sub _dbh_rollback {
+ my $self = shift;
+
+ $self->_dbh->do('ROLLBACK');
+}
+
1;
=head1 NAME
Modified: DBIx-Class/0.08/trunk/t/74mssql.t
===================================================================
--- DBIx-Class/0.08/trunk/t/74mssql.t 2009-11-04 10:00:17 UTC (rev 7845)
+++ DBIx-Class/0.08/trunk/t/74mssql.t 2009-11-06 15:01:30 UTC (rev 7846)
@@ -18,7 +18,7 @@
plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
unless ($dsn);
-my $TESTS = 15;
+my $TESTS = 18;
plan tests => $TESTS * 2;
@@ -145,15 +145,30 @@
$rs->reset;
} 'multiple active statements';
- # test multiple active statements in a transaction
- TODO: {
- local $TODO = 'needs similar FreeTDS fixes to the ones in Sybase.pm';
- lives_ok {
- $schema->txn_do(sub {
- $rs->create({ amount => 400 });
- });
- } 'simple transaction';
- }
+ $rs->delete;
+
+ # test simple transaction with commit
+ lives_ok {
+ $schema->txn_do(sub {
+ $rs->create({ amount => 400 });
+ });
+ } 'simple transaction';
+
+ cmp_ok $rs->first->amount, '==', 400, 'committed';
+ $rs->reset;
+
+ $rs->delete;
+
+ # test rollback
+ throws_ok {
+ $schema->txn_do(sub {
+ $rs->create({ amount => 400 });
+ die 'mtfnpy';
+ });
+ } qr/mtfnpy/, 'simple failed txn';
+
+ is $rs->first, undef, 'rolled back';
+ $rs->reset;
}
# clean up our mess
More information about the Bast-commits
mailing list