Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check collection equality using isEqual: #3223

Closed
wants to merge 2 commits into from

Conversation

jeffdgr8
Copy link
Contributor

@jeffdgr8 jeffdgr8 commented Feb 9, 2024

Use CBLCollection isEqual: for collection equality checks in order to allow separate references to the same collection. This aligns with the behavior in the Java and C SDKs, which allow this.

Also check CBLCollection database instances are equal for equality check, similar to Java SDK.

Copy link
Contributor

@pasin pasin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm checking if there could be any issues when saving a document to a different collection object which is not the one that the document is from.

@@ -525,7 +525,8 @@ - (BOOL) isEqual: (id)object {

if (!(other && [self.name isEqual: other.name] &&
[self.scope.name isEqual: other.scope.name] &&
[self.database.path isEqual: other.database.path])) {
// don't use isEqual: here! The database must be the exact same instance.
self.database == other.database)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen a problem when comparing the database paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with just the first change from != to ![ isEqual:] it broke these tests. The equality check needs to do the check for separate database instances, which then make the collections not equal.

@pasin
Copy link
Contributor

pasin commented Feb 15, 2024

Thanks a lot for creating this PR. I have talked to @bmeike and @borrrden today and we have learnt that each platform has implemented different validation logic when saving the documents and in database / collection equality check. We will have tickets to sync the implementation on each platform. So let me take care this issue.

@pasin pasin closed this Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants