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

Filtering objects with IN query returning incorrect results #6249

Closed
gshahbazian opened this issue Sep 12, 2019 · 3 comments
Closed

Filtering objects with IN query returning incorrect results #6249

gshahbazian opened this issue Sep 12, 2019 · 3 comments

Comments

@gshahbazian
Copy link

gshahbazian commented Sep 12, 2019

Goals

Filter objects with two IN queries eg: "id IN %@ AND NOT name IN %@".

Expected Results

Objects that have an id in the first set and a name in the second set are excluded.

Actual Results

Objects that have an id in the first set and a name in the second set are included. See assert in the sample project.

Steps to Reproduce

Run sample app, hit button in view controller, code asserts.

Code Sample

Download xcode project here: https://www.dropbox.com/s/iud1xt4we4fcuv7/RealmTests.zip?dl=0

Version of Realm and Tooling

ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G95

/Applications/Xcode.app/Contents/Developer
Xcode 11.0
Build version 11A419c

/usr/local/bin/pod
1.7.5
Realm (3.17.3)
RealmSwift (3.17.3)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)

/usr/local/bin/carthage
0.32.0
(not in use here)

/usr/local/bin/git
git version 2.23.0

Note:

  • I am able to reproduce this with Realm 3.15.0 and greater, and also with Xcode 10.3.
  • Adding an index on LabelModel.name fixes the issue.
@tgoyne
Copy link
Member

tgoyne commented Sep 12, 2019

Realm stores string columns in one of three different formats depending on the length of the strings. It looks like the logic introduced in realm/realm-core#3250 is correct for two of the three, but wrong for the "long string" format, and only the short/medium cases are hit by tests.

@tgoyne
Copy link
Member

tgoyne commented Sep 12, 2019

I've made a PR to fix this: realm/realm-core#3386

@bmunkholm
Copy link
Contributor

Was released in 3.19.0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants