Skip to content

Commit

Permalink
Transaction bug fixed
Browse files Browse the repository at this point in the history
AlexDenisov committed Apr 22, 2012
1 parent 2365a24 commit ef8e84c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions iActiveRecord/ActiveRecord.m
Original file line number Diff line number Diff line change
@@ -745,12 +745,13 @@ + (void)disableMigrations {

+ (void)transaction:(ARTransactionBlock)aTransactionBlock {
@synchronized(self){
[[ARDatabaseManager sharedInstance] executeSqlQuery:"SAVEPOINT point"];
[[ARDatabaseManager sharedInstance] executeSqlQuery:"BEGIN"];
@try {
aTransactionBlock();
[[ARDatabaseManager sharedInstance] executeSqlQuery:"COMMIT"];
}
@catch (ARException *exception) {
[[ARDatabaseManager sharedInstance] executeSqlQuery:"ROLLBACK TO point"];
[[ARDatabaseManager sharedInstance] executeSqlQuery:"ROLLBACK"];
}
}
}

0 comments on commit ef8e84c

Please sign in to comment.