Hi all,
Using Realm Flexible sync (in Swift), is it possible to subscribe to a Date-valued queryable field?
I am using the latest Realm release for SwiftUI (11.11.0) and get the following error when I try to set a subscription on date-valued queryable field (‘date’) :
Received QUERY_ERROR “Client provided query with bad syntax: unsupported query for table “DiaryEntry”: server-side queries on timestamp values only supports precision to the millisecond” (error_code=300, query_version=3)
- The function I’m trying to call:
func setSubscriptionDiaryEntriesBeforeToday(realm: Realm) {
let subscriptions = realm.subscriptions
subscriptions.write {
if let currentSubscription = subscriptions.first(named: "diary entry before date") {
currentSubscription.update(toType: DiaryEntry.self) { entry in
entry.date <= Date.now }
} else {
subscriptions.append(QuerySubscription<DiaryEntry>(name: "diary entry before date") { entry in
entry.date <= Date.now
})
}
}
}```
- The class that I’m trying to query results for:
**class** DiaryEntry: Object, ObjectKeyIdentifiable {
@Persisted(primaryKey: **true** ) **var** _id = UUID().uuidString
@Persisted **var** ownerID: String
@Persisted **var** title = ""
@Persisted **var** body = ""
@Persisted **var** date: Date
**convenience** **init** (ownerID: String, title:String = "default", body: String = "default") {
**self** .init()
**self** .ownerID = ownerID
**self** .title = title
**self** .body = body
}
}
- Note I have set ‘date’ as a queryable field using the Realm UI.
- The repo where the error can be reproduced:
GitHub - JuliusHuizing/RealmFlexibleSyncPlayground at timeStampQueryError
Thanks in advance for any suggestions / clarifications!