Skip to content

Commit

Permalink
Fix comparison function for ConditionType
Browse files Browse the repository at this point in the history
The function should ensure strict weak ordering. According to the current one
 {1, 0} == {0, 1} and {0, 1} == {2, 1}
but
 {1, 0} < {2, 1}

It is not possible to construct a failing test as the outcome very much depends
on how the runtime types are laid out.
  • Loading branch information
jedelbo committed Sep 19, 2024
1 parent a3cdfbb commit 96e4469
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* None.

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Having a query with a number of predicates ORed together may result in a crash on some platforms (strict weak ordering check failing on iphone) ([#8028](https://github.com/realm/realm-core/issues/8028), since v14.6.0)
* None.

### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion src/realm/query_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ class OrNode : public ParentNode {
std::type_index m_type;
bool operator<(const ConditionType& other) const
{
return this->m_col < other.m_col && this->m_type < other.m_type;
return (this->m_col == other.m_col) ? this->m_type < other.m_type : this->m_col < other.m_col;
}
bool operator!=(const ConditionType& other) const
{
Expand Down

0 comments on commit 96e4469

Please sign in to comment.