Skip to content

Commit

Permalink
Check collection equality using isEqual:
Browse files Browse the repository at this point in the history
Allow separate references to the same collection
  • Loading branch information
jeffdgr8 committed Feb 9, 2024
1 parent 887ce91 commit f024f6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Objective-C/CBLCollection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ - (BOOL) saveDocument: (CBLDocument*)document
- (BOOL) prepareDocument: (CBLDocument*)document error: (NSError**)error {
if (!document.collection) {
document.collection = self;
} else if (document.collection != self) {
} else if (![document.collection isEqual:self]) {
return createError(CBLErrorInvalidParameter,
kCBLErrorMessageDocumentAnotherCollection, error);
}
Expand Down Expand Up @@ -847,7 +847,7 @@ - (bool) resolveConflictInDocument: (NSString*)docID
resolvedDoc.id, docID);
}

if (resolvedDoc && resolvedDoc.collection && resolvedDoc.collection != self) {
if (resolvedDoc && resolvedDoc.collection && ![resolvedDoc.collection isEqual:self]) {
[NSException raise: NSInternalInconsistencyException
format: kCBLErrorMessageResolvedDocWrongDb,
resolvedDoc.collection.name, self.name];
Expand Down

0 comments on commit f024f6e

Please sign in to comment.