Skip to content

Commit 4c8bd4f

Browse files
committed
Fix AutoPrimaryKey Bug
1 parent 66133a0 commit 4c8bd4f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

SJDBMap/Category/SJDatabaseMap+GetInfo.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,10 @@ - (const char *)sjGetTabName:(Class)cls {
466466
- (NSNumber *)sjGetLastDataIDWithClass:(Class)cls autoincrementPrimaryKeyModel:(SJDBMapAutoincrementPrimaryKeyModel *)aPKM {
467467
NSString *sql = [NSString stringWithFormat:@"SELECT %@ FROM %s ORDER by %@ desc limit 1;", aPKM.ownerFields, [self sjGetTabName:cls], aPKM.ownerFields];
468468
NSDictionary *dict = [self sjQueryWithSQLStr:sql].firstObject;
469-
if ( !dict && !dict.count ) return 0;
470-
return dict[@"goodsID"];
469+
if ( !dict && !dict.count ) return nil;
470+
NSString *fields = [self sjGetAutoPrimaryFields:cls];
471+
if ( 0 == fields.length ) return nil;
472+
return dict[fields];
471473
}
472474

473475
/*!

0 commit comments

Comments
 (0)