From f024f6e83287060549d908f100a5f14277668168 Mon Sep 17 00:00:00 2001 From: Jeff Lockhart Date: Fri, 9 Feb 2024 10:42:33 -0700 Subject: [PATCH] Check collection equality using isEqual: Allow separate references to the same collection --- Objective-C/CBLCollection.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objective-C/CBLCollection.mm b/Objective-C/CBLCollection.mm index 196d2d956..57511cbdd 100644 --- a/Objective-C/CBLCollection.mm +++ b/Objective-C/CBLCollection.mm @@ -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); } @@ -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];