In xcode 9.1 and swift 4.0 branch, compile error is Generic parameter 'D' could not be inferred #186

Closed
opened 2025-12-29 15:26:21 +01:00 by adam · 2 comments
Owner

Originally created by @dhamu-navadiya on GitHub (Nov 11, 2017).

let addedPlant:Plant? = CoreStore.fetchOne(From(), Where("plantid", isEqualTo: self.plant.plantid))

screen shot 2017-11-11 at 10 43 10 pm
Originally created by @dhamu-navadiya on GitHub (Nov 11, 2017). let addedPlant:Plant? = CoreStore.fetchOne(From<Plant>(), Where("plantid", isEqualTo: self.plant.plantid)) <img width="288" alt="screen shot 2017-11-11 at 10 43 10 pm" src="https://user-images.githubusercontent.com/30049650/32691706-c062657c-c731-11e7-8bae-971205f64ab7.png">
adam added the pending docs update label 2025-12-29 15:26:21 +01:00
adam closed this issue 2025-12-29 15:26:21 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Nov 12, 2017):

The Swift 4 update is a major overhaul of the fetching mechanism. In particular, fetch clauses such as Where, OrderBy, and several others are now generic types Where<T>, OrderBy<T>, etc.

For your case you can opt to refactor your code to one of the following syntaxes:

let addedPlant = CoreStore.fetchOne(
    From<Plant>(),
    Where<Plant>("plantid", isEqualTo: self.plant.plantid)
)
let addedPlant = CoreStore.fetchOne(
    From<Plant>()
        .where(\.plantid == self.plant.plantid)
)
let addedPlant = CoreStore.fetchOne(
    From<Plant>()
        .where({ $0.plantid == self.plant.plantid })
)

This will be needed for all your app's fetching code. If you are not ready for a big refactor you can opt to stay with the master or develop branches (version 4.2.x in Cocoapods), which are all on Swift 3.2 and are usable in Xcode 9.1 wether your app is in Xcode 3.2 or 4.0.

The full documentation for the Swift 4 changes (CoreStore 5.0.0) is being rewritten, and I apologize that it's taking some time.

@JohnEstropia commented on GitHub (Nov 12, 2017): The Swift 4 update is a major overhaul of the fetching mechanism. In particular, fetch clauses such as `Where`, `OrderBy`, and several others are now generic types `Where<T>`, `OrderBy<T>`, etc. For your case you can opt to refactor your code to one of the following syntaxes: ```swift let addedPlant = CoreStore.fetchOne( From<Plant>(), Where<Plant>("plantid", isEqualTo: self.plant.plantid) ) ``` ```swift let addedPlant = CoreStore.fetchOne( From<Plant>() .where(\.plantid == self.plant.plantid) ) ``` ```swift let addedPlant = CoreStore.fetchOne( From<Plant>() .where({ $0.plantid == self.plant.plantid }) ) ``` This will be needed for all your app's fetching code. If you are not ready for a big refactor you can opt to stay with the `master` or `develop` branches (version `4.2.x` in Cocoapods), which are all on Swift 3.2 and are usable in Xcode 9.1 wether your app is in Xcode 3.2 or 4.0. The full documentation for the Swift 4 changes (CoreStore 5.0.0) is being rewritten, and I apologize that it's taking some time.
Author
Owner

@JohnEstropia commented on GitHub (Dec 31, 2017):

Version 5 is now released with changesets: https://github.com/JohnEstropia/CoreStore/releases/tag/5.0.0

@JohnEstropia commented on GitHub (Dec 31, 2017): Version 5 is now released with changesets: https://github.com/JohnEstropia/CoreStore/releases/tag/5.0.0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#186