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
Support testing against "now" in predicates #499
Comments
This depends a bit on your definition of "now". If "now" refers to the let currentDate = Date()
let predicate = #Predicate<PlugReminder> { inReminder in
inReminder.fireDate >= currentDate
} But that will capture the current date/time when the predicate is constructed - if the predicate is evaluated at a later date then
|
Yeah, fortunately in my case I was able to solve it as you suggest, at the expense of some brevity in SwiftUI’s In any case, my thought was to be able to specify "now" in a way that gets embedded into the evaluation of the predicate, rather than the creation of it. Most flavors of SQL support this, but iiuc Predicates can be used anywhere, so they probably need their own encoding of "now." |
Just had to mentioned this with regard to static keypaths then: |
Yeah we can keep this issue to track investigating supporting the concept of "now" within the evaluation of the predicate. I think we'll likely want to represent this as |
Today I ran into an issue while converting CoreData code to SwiftData: I couldn't create a
#Predicate
that compared against “now”:This seems to me to be a fairly common use case. Is there a way for
#Predicate
to understand an expression like this?The text was updated successfully, but these errors were encountered: