mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
CoreStoreObject.where is not working (with Swift 4) #146
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @athei on GitHub (Jun 11, 2017).
I am trying to use the type safe where clause. This is the code that i first tried:
CoreStore.fetchOne(From<User>(), User.where { $0.isSelf })Then I get.
Cannot convert value of type 'ValueContainer<V1.User>.Required<Bool>' to closure result type 'Where'This makes sense because the signature of the closure that
CoreStoreObject.whereexpects is:(CoreStoreObject) -> WhereI then wrapped the boolean expression to use the boolean constructor of
Where:CoreStore.fetchOne(From<User>(), User.where { Where($0.isSelf.value) })Then I get an runtime error:
I am puzzled how to use this feature. I am using Swift4. Didn't test it with Xcode8. I guess Swift4 is the reason.
@JohnEstropia commented on GitHub (Jun 11, 2017):
@athei Ah, right now the only way you can do this is by writing
I'll think about allowing unary expressions for boolean attributes.
@athei commented on GitHub (Jun 11, 2017):
Okay did not expect that it was implemented as an overloaded operator. You can't cmd+click these operators :/. Really hard to find the implementation.
@JohnEstropia commented on GitHub (Jun 11, 2017):
I also just realized the README didnt't have documentation on these yet, sorry about that.
In the meantime there are sample usages in the source code documentation in the CoreStoreObject+Querying.swift file that you can refer to, as well as unit test cases in the DynamicModelTests.swift file.
@athei commented on GitHub (Jun 11, 2017):
No need to apologise. I would recommend adding one sentence describing that unary is not possible because of the operator implementation.
I guess this can be closed now.
@JohnEstropia commented on GitHub (Jun 11, 2017):
Thanks for your feedback!