ios – How to compare an optional field to a non-optional field in Realm queries?


I am trying to use the Realm query api in Swift to filter on the following Realm object:

public class Photo: Object {

    @Persisted(primaryKey: true) var photoID: UUID
    @Persisted(indexed: true) var remoteDateLastUpdated: Date?
    @Persisted(indexed: true) var localDateLastUpdated: Date

Notice that the one of the Date fields is optional and the other is not. I am trying to query this object like so:

    let photosToPush ={
        $0.remoteDateLastUpdated != $0.localDateLastUpdated

But I am getting the error Cannot convert value of type Query<Date> to expected argument type ‘Query<Date?>’

How can I typecast this to make this query work?