Closed lukenewman closed 6 years ago
Closing because you can't query on a computed property. The correct approach here is to filter by == nil
. My anecdotal issue was tied to an incorrectly-set-up relationship. Make sure you're getting your children based on the correct ID!
I have a
Session
model which has an entry and exit timestamp. Sessions are.active
when the exit timestamp isnil
and.finished
otherwise:I then want to filter based on
state
:For testing, I have only one Session in the database, and it has a
nil
exitTimestamp
.listActive
returns nothing, butlistInactive
returns said Session, opposite my expectations.I understand this issue is very anecdotal -- and it very well may be that the error lies in my code -- but it also may lie in the intricacies of Postgre or this package.
This is one of many approaches I've taken to filtering based on an Optional property's existence. Attempts to filter by other means (
.filter(\.exitTimestamp == nil)
,.filter(\.isActive)
) were not fruitful.Please let me know what other information I can provide. Thanks!