Skip to content

Commit

Permalink
Fill lastInsertedRowID
Browse files Browse the repository at this point in the history
  • Loading branch information
RingoD committed Jul 5, 2017
1 parent 536976a commit 1803a1f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apple/WCDB/interface/chaincall/WCTInsert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ - (BOOL)doInsertObjects:(NSArray<WCTObject *> *)objects withError:(WCDB::Error &
return NO;
}
int index;
BOOL isAutoIncrement;
BOOL fillLastInsertedRowID = [objects[0] respondsToSelector:@selector(lastInsertedRowID)];
for (WCTObject *object in objects) {
index = 1;
isAutoIncrement = NO;
for (const WCTProperty &property : _propertyList) {
const std::shared_ptr<WCTColumnBinding> &columnBinding = property.getColumnBinding();
if (!_replace && columnBinding->isPrimary() && columnBinding->isAutoIncrement() && object.isAutoIncrement) {
statementHandle->bind<(WCDB::ColumnType) WCTColumnTypeNil>(index);
isAutoIncrement = YES;
} else {
if (![self bindProperty:property
ofObject:object
Expand All @@ -113,7 +111,7 @@ - (BOOL)doInsertObjects:(NSArray<WCTObject *> *)objects withError:(WCDB::Error &
error = statementHandle->getError();
return NO;
}
if (isAutoIncrement) {
if (fillLastInsertedRowID) {
object.lastInsertedRowID = statementHandle->getLastInsertedRowID();
}
statementHandle->resetBinding();
Expand Down

0 comments on commit 1803a1f

Please sign in to comment.