You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since type-safe keyPath syntax was added to Realm, I would expect that syntax to work everywhere, not just in queries. It does not appear to work with observe or updating/creating an object
A query pre 10.11.0. would be
let dogsSorted = dogs.sorted(byKeyPath: "name")
and the from 10.11.0. forward we can use
let dogsSorted = dogs.sorted(by: \.name)
That same syntax should work when updating objects (and everywhere else) as well.
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
Supposed we have a Person object with the required primary key and a name string
class Person: Object {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var name = ""
}
How frequently does the bug occur?
Always
Description
Since type-safe keyPath syntax was added to Realm, I would expect that syntax to work everywhere, not just in queries. It does not appear to work with observe or updating/creating an object
A query pre 10.11.0. would be
let dogsSorted = dogs.sorted(byKeyPath: "name")
and the from 10.11.0. forward we can use
let dogsSorted = dogs.sorted(by: \.name)
That same syntax should work when updating objects (and everywhere else) as well.
Stacktrace & log output
No response
Can you reproduce the bug?
Always
Reproduction Steps
Supposed we have a Person object with the required primary key and a name string
create an object and write it to Realm
then later, read that object in to update the name via the
\.name
keypathoutputs
Now modify the name using type-safe keyPath
and the output
Note that neither the _id nor the name was property populated. However, using Strings as keys does work
outputs
Note the primary key is the same and the name was updated.
Version
10.48.1
What Atlas Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
macOS Sonoma 14.2.1
Build environment
Xcode version: 15.3
Dependency manager and version: Realm 10.48.1
The text was updated successfully, but these errors were encountered: