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

Queries with multiple OR statements does not work on RLMArrays #1725

Closed
dzhng opened this issue Apr 3, 2015 · 8 comments
Closed

Queries with multiple OR statements does not work on RLMArrays #1725

dzhng opened this issue Apr 3, 2015 · 8 comments
Labels
Blocked This issue is blocked by another issue T-Bug

Comments

@dzhng
Copy link

dzhng commented Apr 3, 2015

Here's my use case, I have a pretty big RLMArrays of contacts, I'm trying to implement search through the list of contacts.

Right now my contacts schema contains: firstname, lastname, email.

My query is: "firstname BEGINSWITH[c] %@ OR lastname BEGINSWITH[c] %@ OR email BEGINSWITH[c] %@". However, this always seem to reproduce incomplete results.

If I cut the query down to just one field, e.g. "firstname BEGINSWITH[c] %@", without any OR statements, it works as intended.

I also tried different comparators like "CONTAINS" and with/without case insensitivity, it doesn't make any difference.

I can reproduce this issue on both iOS and Android, so seems like an realm core issue.

@segiddins
Copy link
Contributor

@dzz0615, would it be possible to provide us with a sample project that demonstrates the deviation from expected results? That would make it much easier to track down what's going on. Thanks!

@nicholascross
Copy link

This is possibly related, I recently noticed what seems to be a problem with OR queries as well, but it only seemed to happen after a certain combination of updates.

[self.priorities objectsWhere:@"isComplete == %@ OR dateModified > %@", @(0), sinceDate];

would return expected the results expected initially but after updating some properties and deleting a record the same queries no longer returns the expected results.

As expected the priority that was deleted, is no longer returned, what is strange is that an additional record is also not returned even though its properties still match the query.

[self.priorities objectsWhere:@"dateModified > %@", sinceDate];
[self.priorities objectsWhere:@"isComplete == %@", @(0)];

The above two queries as well as accessing self.priorities will return expected results, which led me to believe the problem might lie with the OR operand. I am still investigating.

@segiddins
Copy link
Contributor

@nacrossweb if you could share your project (or another that reproduces the issue) with us (you can do so privately at help@realm.io if you prefer) would be incredibly helpful.

@nicholascross
Copy link

@segiddins I managed to track this down. Now that I have I am less sure if it is the same problem but it is definitely a bug. It seems to be some how connected to the deletion of the first child in an RLMArray, after this child is deleted subsequent OR queries give unreliable results.

If you dump this gist into an empty project you should be able to see what I mean. Deleting any other child will not trigger the bug.

@segiddins
Copy link
Contributor

@nacrossweb thanks! We've seen some bugs in that scenario before, I'll dig into the repro case on Monday.

@segiddins segiddins added T-Bug and removed pending labels Apr 5, 2015
@segiddins segiddins self-assigned this Apr 5, 2015
@segiddins
Copy link
Contributor

After looking through the Core's history, I can see that we potentially have a fix in the pipeline.

@segiddins segiddins added the P2 label Apr 6, 2015
@segiddins
Copy link
Contributor

I can confirm this bug is still an issue, and have made a ticket for our core team. Thanks @nacrossweb !

@timanglade timanglade added P1 and removed P2 labels Apr 28, 2015
@segiddins segiddins added the Blocked This issue is blocked by another issue label Apr 29, 2015
@segiddins segiddins removed their assignment Apr 29, 2015
@tgoyne
Copy link
Member

tgoyne commented May 21, 2015

This was fixed in 0.92.3.

@tgoyne tgoyne closed this as completed May 21, 2015
@tgoyne tgoyne removed the P1 label May 21, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Blocked This issue is blocked by another issue T-Bug
Projects
None yet
Development

No branches or pull requests

5 participants