Skip to content

Commit 88d3608

Browse files
committed
增加非空判断
1 parent c203530 commit 88d3608

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

LKDBHelper/Helper/LKDBHelper.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ - (void)dropAllTable
507507
NSMutableArray* dropTables = [NSMutableArray arrayWithCapacity:0];
508508

509509
while ([set next]) {
510-
[dropTables addObject:[set stringForColumnIndex:0]];
510+
NSString* tableName = [set stringForColumnIndex:0];
511+
if (tableName) {
512+
[dropTables addObject:tableName];
513+
}
511514
}
512515

513516
[set close];
@@ -1062,7 +1065,10 @@ - (NSMutableArray*)executeResult:(FMResultSet*)set Class:(Class)modelClass table
10621065

10631066
while ([set next]) {
10641067
NSObject* bindingModel = [[modelClass alloc] init];
1065-
1068+
if (bindingModel == nil) {
1069+
continue;
1070+
}
1071+
10661072
for (int i = 0; i < columnCount; i++) {
10671073
NSString* sqlName = [set columnNameForIndex:i];
10681074
LKDBProperty* property = [infos objectWithSqlColumnName:sqlName];
@@ -1188,7 +1194,9 @@ - (BOOL)insertBase:(NSObject*)model
11881194
}
11891195

11901196
id value = [self modelValueWithProperty:property model:model];
1191-
1197+
if (value == nil) {
1198+
continue;
1199+
}
11921200
///跳过 rowid = 0 的属性
11931201
if ([property.sqlColumnName isEqualToString:@"rowid"] && ([value intValue] == 0)) {
11941202
continue;
@@ -1279,6 +1287,9 @@ - (BOOL)updateToDBBase:(NSObject*)model where:(id)where
12791287
continue;
12801288
}
12811289
id value = [self modelValueWithProperty:property model:model];
1290+
if (value == nil) {
1291+
continue;
1292+
}
12821293
///跳过 rowid = 0 的属性
12831294
if ([property.sqlColumnName isEqualToString:@"rowid"]) {
12841295
int rowid = [value intValue];

0 commit comments

Comments
 (0)