Chain .where clause #239

Closed
opened 2025-12-29 18:24:43 +01:00 by adam · 3 comments
Owner

Originally created by @markst on GitHub (Nov 9, 2018).

There doesn't seem to be any documentation on whether chaining multiple where clauses is possible?

It appears the following doesn't work:

return CoreStore.fetchCount(
    From<Booking>()
        .where(\.customer == self)
        .where(\.bookingStatus == BookingStatus.cancelled.rawValue)
    ) ?? 0

and must be expressed as a single predicate.

Originally created by @markst on GitHub (Nov 9, 2018). There doesn't seem to be any documentation on whether chaining multiple `where` clauses is possible? It appears the following doesn't work: ```swift return CoreStore.fetchCount( From<Booking>() .where(\.customer == self) .where(\.bookingStatus == BookingStatus.cancelled.rawValue) ) ?? 0 ``` and must be expressed as a single predicate.
adam added the question label 2025-12-29 18:24:43 +01:00
adam closed this issue 2025-12-29 18:24:43 +01:00
Author
Owner

@markst commented on GitHub (Nov 9, 2018):

45e110755d/Sources/Where.swift (L273)

@markst commented on GitHub (Nov 9, 2018): https://github.com/JohnEstropia/CoreStore/blob/45e110755dd5ac3af201b9d8ff16f2af909f6539/Sources/Where.swift#L273
Author
Owner

@JohnEstropia commented on GitHub (Nov 9, 2018):

You can use && and || operators instead:

return CoreStore.fetchCount(
    From<Booking>()
        .where(\.customer == self && \.bookingStatus == BookingStatus.cancelled.rawValue)
    ) ?? 0
@JohnEstropia commented on GitHub (Nov 9, 2018): You can use `&&` and `||` operators instead: ```swift return CoreStore.fetchCount( From<Booking>() .where(\.customer == self && \.bookingStatus == BookingStatus.cancelled.rawValue) ) ?? 0 ```
Author
Owner

@markst commented on GitHub (Nov 9, 2018):

Thanks. Just no mention of it in readme.

@markst commented on GitHub (Nov 9, 2018): Thanks. Just no mention of it in readme.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#239