Skip to content

Fix crash when negating query with empty group#7234

Draft
rorbech wants to merge 2 commits into
releasesfrom
cr/not-with-empty-group
Draft

Fix crash when negating query with empty group#7234
rorbech wants to merge 2 commits into
releasesfrom
cr/not-with-empty-group

Conversation

@rorbech

@rorbech rorbech commented Dec 4, 2020

Copy link
Copy Markdown
Contributor

Currently just added tests for queries with empty groups

Closes #7233

@cmelchior cmelchior left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few comments on how the tests are written + we do need a changelog entry for it.

RealmResults<AllTypes> fives = realm.where(AllTypes.class)
.equalTo(AllTypes.FIELD_LONG, 5)
.beginGroup()
.endGroup()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't this throw as well?

@rorbech rorbech Dec 4, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No 🤷

assertEquals(1, fives.size());
}

@Test (expected = UnsupportedOperationException.class)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally, we only reserve this exception to things not implemented. A more appropriate exception would be IllegalStateException

@rorbech rorbech Dec 4, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From documentation of the various RealmQuery methods it seems like invalid queries (syntax errors) are indicated by throwing UnsupportedOperationException.

Comment thread realm/realm-library/src/androidTest/java/io/realm/RealmQueryTests.java Outdated
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