Эх сурвалжийг харах

Simplify savepoint code

Some of the savepoint code were calling `executeUpdate and building the error and then returning the value accordingly. This can be streamlined by just calling `execugteUpdate:error:withArgumentsInArray:orDictionary:orVAList:`.
Robert M. Ryan 10 жил өмнө
parent
commit
4c01521a46

+ 5 - 24
src/fmdb/FMDatabase.m

@@ -1309,16 +1309,7 @@ - (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr {
     
     
     NSString *sql = [NSString stringWithFormat:@"savepoint '%@';", FMDBEscapeSavePointName(name)];
     NSString *sql = [NSString stringWithFormat:@"savepoint '%@';", FMDBEscapeSavePointName(name)];
     
     
-    if (![self executeUpdate:sql]) {
-
-        if (outErr) {
-            *outErr = [self lastError];
-        }
-        
-        return NO;
-    }
-    
-    return YES;
+    return [self executeUpdate:sql error:outErr withArgumentsInArray:nil orDictionary:nil orVAList:nil];
 #else
 #else
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     if (self.logsErrors) NSLog(@"%@", errorMessage);
     if (self.logsErrors) NSLog(@"%@", errorMessage);
@@ -1331,13 +1322,8 @@ - (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr {
     NSParameterAssert(name);
     NSParameterAssert(name);
     
     
     NSString *sql = [NSString stringWithFormat:@"release savepoint '%@';", FMDBEscapeSavePointName(name)];
     NSString *sql = [NSString stringWithFormat:@"release savepoint '%@';", FMDBEscapeSavePointName(name)];
-    BOOL worked = [self executeUpdate:sql];
-    
-    if (!worked && outErr) {
-        *outErr = [self lastError];
-    }
-    
-    return worked;
+
+    return [self executeUpdate:sql error:outErr withArgumentsInArray:nil orDictionary:nil orVAList:nil];
 #else
 #else
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     if (self.logsErrors) NSLog(@"%@", errorMessage);
     if (self.logsErrors) NSLog(@"%@", errorMessage);
@@ -1350,13 +1336,8 @@ - (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr {
     NSParameterAssert(name);
     NSParameterAssert(name);
     
     
     NSString *sql = [NSString stringWithFormat:@"rollback transaction to savepoint '%@';", FMDBEscapeSavePointName(name)];
     NSString *sql = [NSString stringWithFormat:@"rollback transaction to savepoint '%@';", FMDBEscapeSavePointName(name)];
-    BOOL worked = [self executeUpdate:sql];
-    
-    if (!worked && outErr) {
-        *outErr = [self lastError];
-    }
-    
-    return worked;
+
+    return [self executeUpdate:sql error:outErr withArgumentsInArray:nil orDictionary:nil orVAList:nil];
 #else
 #else
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
     if (self.logsErrors) NSLog(@"%@", errorMessage);
     if (self.logsErrors) NSLog(@"%@", errorMessage);