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

RDART-1006: Reference equality implies equality #1633

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

### Fixed
* Using valid const, but non-literal expressions, such as negation of numbers, as an initializer would fail. (Issue [#1606](https://github.com/realm/realm-dart/issues/1606))
* Backlinks mistakenly included in EJson serialization. ([Issue #1616](https://github.com/realm/realm-dart/issues/1616))
* Backlinks mistakenly included in EJson serialization. (Issue [#1616](https://github.com/realm/realm-dart/issues/1616))
* Fix an assertion failure "m_lock_info && m_lock_info->m_file.get_path() == m_filename" that appears to be related to opening a Realm while the file is in the process of being closed on another thread. (Core 14.5.0)
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). (Core 14.5.0)
* Null pointer exception may be triggered when logging out and async commits callbacks not executed. (Core 14.5.0)
* Comparing RealmValue containing a collection to itself would return false. Semantics changed to ensure reference equality always imply equality. (Issue [[#1632](https://github.com/realm/realm-dart/issues/1632)])

### Compatibility
* Realm Studio: 15.0.0 or later.
Expand Down
20 changes: 3 additions & 17 deletions packages/realm_common/lib/src/realm_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,28 +278,14 @@ class RealmValue {

@override
operator ==(Object other) {
// TODO(kn):
// Should we not start by testing for identical? Will break current
// test, but I think the tests are wrong
//if (identical(this, other)) return true;

// We always return false when comparing two RealmValue collections.
if (type.isCollection) {
return false;
}

if (identical(this, other)) return true;
final v = value;

if (other is RealmValue) {
final ov = other.value;
if (v is Uint8List && ov is Uint8List) {
return memEquals(v, ov);
}

if (v is Uint8List && ov is Uint8List) return memEquals(v, ov); // special case binary data
return type == other.type && v == ov;
}

return v == other;
return v == other; // asymmetric comparison for convenience
}

@override
Expand Down
Loading
Loading