-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Query Syntax: Incorrect NSPredicate When Using .values
on a Map Property
#8654
Comments
➤ PM Bot commented: Jira ticket: RCOCOA-2412 |
.values
on a Map Property?.values
on a Map Property
Updated the issue with a more concise summary. An Aside:It would be nice if the Realm Query Syntax API were smart enough to add
The compiler showed no errors here, but at runtime the resulting predicate failed to parse and it took me a minute to realize why, since the other issue with |
I am not exactly sure what the expected result is so let me take a crack at it. Looking at the code - it appears the goal is to return all Bar objects where the flags Map property contains isLoud == true. Allow me to set up a test case
So the result here is that bar0's flags property "b" key contains value f1 where The goal is return bar0 since it has at least one Doesn't this query solve that?
and the result is bar 0
likewise if we change f2, which is in
I think the Let me know if the desired result is different than my guess. |
Perhaps I've not been clear. Realm translates Whether In other words, adding (In my actual app, there's several parts to this query. I've narrowed it down to a simplified example.) |
@Jaycyn here's another way to see the problem: suppose we wanted to fetch all Now |
Duplicated. Kinda odd as well. Looks like the placement is in the wrong place as you mentioned. This predicate as suggest in the initial report works and has the correct placement for @allvalues
|
Is there anything else you guys need to fix this? My workaround eliminates type safety and adds fragility, so I'd like to get back to the Realm Query Syntax when this is solved. I'm unclear if @Jaycyn works for Mongo, but he was able to duplicate the bug at least. |
No, I do not work for Mongo and yes this is definitely not working as intended. I would also not set an expectation this will be reviewed any time soon. Support for the platform appears to be minimal at this time - hardly a peep from anyone in months. Perhaps there's simply not enough support employees to handle the amount or depth of issues? Hopefully they will acknowledge and get to it in the future. Your workaround, while not ideal, will be your best bet. |
@Jaycyn I noticed a drop off in project momentum (like features) and support once the focus shifted to the sync service. Even major core features such as full-text search are absent from RealmSwift. Most updates for a long while are centered around syncing now, which is their business model. I don't use the syncing so it has been especially frustrating to see this stall out, especially now that SwiftData has released and shown itself to be relatively immature and unusable, leaving few alternatives / hope for the future. (Sorry for the aside.) (edit: There are some hard working employees who do follow up sometimes if you ping them directly in here - don't mean to shade their service when the above is a complaint about their employer's direction) |
I don't mean to dismiss your concerns and I'll be the first to admit we have shifted focus. This is not surprising though - Realm is no longer a startup, it's part of MongoDB which is for-profit business and it's expected that paying customers would be prioritized in the current macroeconomic environment. Obviously issues with the core database affect those customers, so we're trying to address them based on feedback and open tickets, but we only have limited resources and we have to be very deliberate deciding what to work on. That being said, Realm is a fully open source project and if members of the community are willing to dip their feet in SDK development, we'd be happy to merge well thought out and tested PRs, even if they primarily benefit local use cases. |
It's not my intent to start a "local vs sync" debate. (I think I'm actually one of the heaviest Atlas Device Sync users around--at least in how much my app demands from the service, if not in sheer database size. I've gathered that I'm an edge case for the sync service, at least.) This bug isn't really a local-vs.-sync issue; it affects both groups. The issue has been silent for a month and didn't have any replies from Mongo staff, so I was just following up. |
Thanks for that insight @nirinchev I think it would help us to understand the direction if this is an acknowledged bug or if we are simply doing something wrong/incorrect expectation and it's working as intended. If so, can you provide clarity on how it should be done? Regardless of Sync/No Sync, Realm is promoted as an "Offline first database" So while shifting focus is great because sync'ing is very important, having focus on the Offline First aspect is equally as important. Many of the bugs we encounter affect both, and if your core isn't solid, sync'ing will be a mess. IMO, we've been in limbo for a couple of years, unable to release products backed by Realm. So while shifting focus is warranted, not addressing core Realm SDK (errr, Atlas Device SDK) issues like this prevent us from becoming paying customers. |
It's definitely a bug or at least a use case we didn't think through. And I completely agree - it's a deficiency that impacts both paying customers and people using the open source local-only database. I was merely trying to provide context for why it hasn't been addressed in a while - we have limited resources, this issue has a workaround - even if unpleasant - and there are more pressing tasks we have been focusing on. |
How frequently does the bug occur?
Always
Description
Consider these objects:
I want to query the database for all
Bar
objects whoseflags
map contains a loudFlag
. So I write this:Realm transforms that query syntax into this
NSPredicate
, which throws an exception at runtime:I think
@allValues
is misplaced here because each value in the collection (referenced by the variable$col1
) does not have an@allValues
property; it's a single object. I think the correctNSPredicate
should be:Replacing the Realm-Query-Syntax-Produced predicate with this manual one resolves the exception. (I don't know if it actually fetches the
Bar
objects yet, though, because I got sucked into this issue.)Can you reproduce the bug?
Always
Reproduction Steps
Run the sample code above.
Version
10.52.1
What Atlas Services are you using?
Both Atlas Device Sync and Atlas App Services
Are you using encryption?
No
Platform OS and version(s)
macOS 14.3
Build environment
Xcode version: 16 Beta 3
Dependency manager and version: SPM
The text was updated successfully, but these errors were encountered: