Skip to content

Commit

Permalink
fix(ios): properly report partial results on thrown error for Ti.DB.e…
Browse files Browse the repository at this point in the history
…xecuteAll
  • Loading branch information
sgtcoolguy committed Jul 16, 2020
1 parent 8a639d8 commit f1372ba
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions iphone/Classes/TiDatabaseProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,25 @@ - (void)executeAsync:(NSString *)sql
- (NSArray<TiDatabaseResultSetProxy *> *)executeAll:(NSArray<NSString *> *)queries
{
NSError *error = nil;
JSContext *context = [JSContext currentContext];
JSContext *context = JSContext.currentContext;
NSMutableArray *results = [NSMutableArray arrayWithCapacity:[queries count]];
NSUInteger index = 0;
for (NSString *sql in queries) {
TiDatabaseResultSetProxy *result = [self executeSQL:sql withParams:nil withError:&error];
if (result == nil) {
[results addObject:[JSValue valueWithNullInContext:context]];
} else {
[results addObject:result];
}

if (error != nil) {
JSValue *jsError = [self createError:@"failed to execute SQL statements" subreason:[error description] location:CODELOCATION inContext:context];
jsError[@"results"] = result;
jsError[@"results"] = results;
jsError[@"index"] = [NSNumber numberWithUnsignedInteger:index];
[context setException:jsError];
return nil;
}
if (result == nil) {
[results addObject:[JSValue valueWithNullInContext:context]];
} else {
[results addObject:result];
}

index++;
}
return results;
Expand Down

0 comments on commit f1372ba

Please sign in to comment.