-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Realm Object isEqual(_:) override #7781
Comments
|
Hi @igorvoytovich you should be able to compare between two detached (frozen) objects without overriding the |
Hi @dianaafanador3, Thank you for your response. We use this code: #5433 (comment) We can not use Realm's frozen objects due to their implementation nuances. (realm/realm-core#5043 (comment)) |
|
ok I understand. Regarding overriding |
|
Thanks @dianaafanador3 , This is exactly what we wanted to know. There were fears that this function can be used somewhere inside the Realm internal logic, for example, when updating objects with a primary key, in order to check for the presence of an object in database or something like that. Now it's all clear. Thanks again! We can close this case now. |
So can we just override that |
Hello,
Could you please tell if it is safe to override:
{{func isEqual(_ object: Any?) -> Bool { ... }}}
for Realm Objects?
I heard that Realm objects with primaryKey override it by default, but we use detached objects in several cases and need to be able to compare them too.
For example, if we have:
If we add:
to this class,
Can something break or go wrong? Could this lead to some unexpected behavior in production or is it completely safe?
Thanks.
P.S.
Or maybe you can tell how to correctly implement objects comparison so that it works for detached objects as well? Maybe something related to Hashable and hashValue would be more correct?
The text was updated successfully, but these errors were encountered: