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.where expects is: (CoreStoreObject) -> Where
I 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:
❗ [CoreStore: Assertion Failure] Value.swift:148 value
↪︎ Attempted to access values from a 'User' meta object. Meta objects are only used for querying keyPaths and infering types.
I am puzzled how to use this feature. I am using Swift4. Didn't test it with Xcode8. I guess Swift4 is the reason.
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.where` expects is:
`(CoreStoreObject) -> Where`
I 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:
```
❗ [CoreStore: Assertion Failure] Value.swift:148 value
↪︎ Attempted to access values from a 'User' meta object. Meta objects are only used for querying keyPaths and infering types.
```
I am puzzled how to use this feature. I am using Swift4. Didn't test it with Xcode8. I guess Swift4 is the reason.
adam
added the question label 2025-12-29 15:25:31 +01:00
@athei Ah, right now the only way you can do this is by writing
User.where{$0.isSelf==true}
I'll think about allowing unary expressions for boolean attributes.
@JohnEstropia commented on GitHub (Jun 11, 2017):
@athei Ah, right now the only way you can do this is by writing
```swift
User.where { $0.isSelf == true }
```
I'll think about allowing unary expressions for boolean attributes.
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.
@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.
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.
@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.
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.
@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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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!