diff --git a/CoreStoreTests/WhereTests.swift b/CoreStoreTests/WhereTests.swift index da7aaaf..d9b2ed5 100644 --- a/CoreStoreTests/WhereTests.swift +++ b/CoreStoreTests/WhereTests.swift @@ -31,12 +31,12 @@ import CoreStore // MARK: - XCTAssertAllEqual -private func XCTAssertAllEqual(_ whereClauses: Where...) { +private func XCTAssertAllEqual(_ whereClauses: Where...) { XCTAssertAllEqual(whereClauses) } -private func XCTAssertAllEqual(_ whereClauses: [Where]) { +private func XCTAssertAllEqual(_ whereClauses: [Where]) { for i in whereClauses.indices { diff --git a/Sources/AsynchronousDataTransaction.swift b/Sources/AsynchronousDataTransaction.swift index 002f566..874f098 100644 --- a/Sources/AsynchronousDataTransaction.swift +++ b/Sources/AsynchronousDataTransaction.swift @@ -66,7 +66,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration - returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type. */ - public override func create(_ into: Into) -> D { + public override func create(_ into: Into) -> O { Internals.assert( !self.isCommitted, @@ -82,7 +82,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter object: the `NSManagedObject` or `CoreStoreObject` to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public override func edit(_ object: D?) -> D? { + public override func edit(_ object: O?) -> O? { Internals.assert( !self.isCommitted, @@ -99,7 +99,7 @@ public final class AsynchronousDataTransaction: BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public override func edit(_ into: Into, _ objectID: NSManagedObjectID) -> D? { + public override func edit(_ into: Into, _ objectID: NSManagedObjectID) -> O? { Internals.assert( !self.isCommitted, diff --git a/Sources/BaseDataTransaction+Importing.swift b/Sources/BaseDataTransaction+Importing.swift index c18e78f..3d6e742 100644 --- a/Sources/BaseDataTransaction+Importing.swift +++ b/Sources/BaseDataTransaction+Importing.swift @@ -39,9 +39,9 @@ extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableObject` methods - returns: the created `ImportableObject` instance, or `nil` if the import was ignored */ - public func importObject( - _ into: Into, - source: D.ImportSource) throws -> D? { + public func importObject( + _ into: Into, + source: O.ImportSource) throws -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -65,13 +65,13 @@ extension BaseDataTransaction { /** Updates an existing `ImportableObject` by importing values from the specified import source. - - parameter object: the `NSManagedObject` to update + - parameter object: the `ImportableObject` to update - parameter source: the object to import values from - throws: an `Error` thrown from any of the `ImportableObject` methods */ - public func importObject( - _ object: D, - source: D.ImportSource) throws { + public func importObject( + _ object: O, + source: O.ImportSource) throws { Internals.assert( self.isRunningInAllowedQueue(), @@ -97,9 +97,9 @@ extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableObject` methods - returns: the array of created `ImportableObject` instances */ - public func importObjects( - _ into: Into, - sourceArray: S) throws -> [D] where S.Iterator.Element == D.ImportSource { + public func importObjects( + _ into: Into, + sourceArray: S) throws -> [O] where S.Iterator.Element == O.ImportSource { Internals.assert( self.isRunningInAllowedQueue(), @@ -108,7 +108,7 @@ extension BaseDataTransaction { return try autoreleasepool { - return try sourceArray.compactMap { (source) -> D? in + return try sourceArray.compactMap { (source) -> O? in let entityType = into.entityClass guard entityType.shouldInsert(from: source, in: self) else { @@ -133,9 +133,9 @@ extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableUniqueObject` methods - returns: the created/updated `ImportableUniqueObject` instance, or `nil` if the import was ignored */ - public func importUniqueObject( - _ into: Into, - source: D.ImportSource) throws -> D? { + public func importUniqueObject( + _ into: Into, + source: O.ImportSource) throws -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -151,7 +151,7 @@ extension BaseDataTransaction { return nil } - if let object = try self.fetchOne(From(entityType), Where(uniqueIDKeyPath, isEqualTo: uniqueIDValue)) { + if let object = try self.fetchOne(From(entityType), Where(uniqueIDKeyPath, isEqualTo: uniqueIDValue)) { guard entityType.shouldUpdate(from: source, in: self) else { @@ -185,10 +185,10 @@ extension BaseDataTransaction { - throws: an `Error` thrown from any of the `ImportableUniqueObject` methods - returns: the array of created/updated `ImportableUniqueObject` instances */ - public func importUniqueObjects( - _ into: Into, + public func importUniqueObjects( + _ into: Into, sourceArray: S, - preProcess: @escaping (_ mapping: [D.UniqueIDType: D.ImportSource]) throws -> [D.UniqueIDType: D.ImportSource] = { $0 }) throws -> [D] where S.Iterator.Element == D.ImportSource { + preProcess: @escaping (_ mapping: [O.UniqueIDType: O.ImportSource]) throws -> [O.UniqueIDType: O.ImportSource] = { $0 }) throws -> [O] where S.Iterator.Element == O.ImportSource { Internals.assert( self.isRunningInAllowedQueue(), @@ -198,10 +198,10 @@ extension BaseDataTransaction { return try autoreleasepool { let entityType = into.entityClass - var importSourceByID = Dictionary() + var importSourceByID = Dictionary() let sortedIDs = try autoreleasepool { - return try sourceArray.compactMap { (source) -> D.UniqueIDType? in + return try sourceArray.compactMap { (source) -> O.UniqueIDType? in guard let uniqueIDValue = try entityType.uniqueID(from: source, in: self) else { @@ -214,13 +214,13 @@ extension BaseDataTransaction { importSourceByID = try autoreleasepool { try preProcess(importSourceByID) } - var existingObjectsByID = Dictionary() + var existingObjectsByID = Dictionary() try self - .fetchAll(From(entityType), Where(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs)) + .fetchAll(From(entityType), Where(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs)) .forEach { existingObjectsByID[$0.uniqueIDValue] = $0 } - var processedObjectIDs = Set() - var result = [D]() + var processedObjectIDs = Set() + var result = [O]() for objectID in sortedIDs where !processedObjectIDs.contains(objectID) { diff --git a/Sources/BaseDataTransaction+Querying.swift b/Sources/BaseDataTransaction+Querying.swift index 7485e76..7345acf 100644 --- a/Sources/BaseDataTransaction+Querying.swift +++ b/Sources/BaseDataTransaction+Querying.swift @@ -39,7 +39,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s deleted */ @discardableResult - public func deleteAll(_ from: From, _ deleteClauses: DeleteClause...) throws -> Int { + public func deleteAll(_ from: From, _ deleteClauses: DeleteClause...) throws -> Int { Internals.assert( self.isRunningInAllowedQueue(), @@ -56,7 +56,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s deleted */ @discardableResult - public func deleteAll(_ from: From, _ deleteClauses: [DeleteClause]) throws -> Int { + public func deleteAll(_ from: From, _ deleteClauses: [DeleteClause]) throws -> Int { Internals.assert( self.isRunningInAllowedQueue(), @@ -93,7 +93,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter object: a reference to the object created/fetched outside the transaction - returns: the `DynamicObject` instance if the object exists in the transaction, or `nil` if not found. */ - public func fetchExisting(_ object: D) -> D? { + public func fetchExisting(_ object: O) -> O? { return self.context.fetchExisting(object) } @@ -104,7 +104,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `DynamicObject` instance if the object exists in the transaction, or `nil` if not found. */ - public func fetchExisting(_ objectID: NSManagedObjectID) -> D? { + public func fetchExisting(_ objectID: NSManagedObjectID) -> O? { return self.context.fetchExisting(objectID) } @@ -115,7 +115,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter objects: an array of `DynamicObject`s created/fetched outside the transaction - returns: the `DynamicObject` array for objects that exists in the transaction */ - public func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D { + public func fetchExisting(_ objects: S) -> [O] where S.Iterator.Element == O { return self.context.fetchExisting(objects) } @@ -126,7 +126,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `DynamicObject` array for objects that exists in the transaction */ - public func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID { + public func fetchExisting(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID { return self.context.fetchExisting(objectIDs) } @@ -139,7 +139,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -156,7 +156,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -195,7 +195,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [O] { Internals.assert( self.isRunningInAllowedQueue(), @@ -212,7 +212,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [O] { Internals.assert( self.isRunningInAllowedQueue(), @@ -251,7 +251,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { Internals.assert( self.isRunningInAllowedQueue(), @@ -268,7 +268,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { Internals.assert( self.isRunningInAllowedQueue(), @@ -307,7 +307,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { Internals.assert( self.isRunningInAllowedQueue(), @@ -324,7 +324,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { Internals.assert( self.isRunningInAllowedQueue(), @@ -363,7 +363,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { Internals.assert( self.isRunningInAllowedQueue(), @@ -380,7 +380,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { Internals.assert( self.isRunningInAllowedQueue(), @@ -425,7 +425,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { Internals.assert( self.isRunningInAllowedQueue(), @@ -445,7 +445,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { Internals.assert( self.isRunningInAllowedQueue(), @@ -489,7 +489,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { Internals.assert( self.isRunningInAllowedQueue(), @@ -509,7 +509,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { Internals.assert( self.isRunningInAllowedQueue(), diff --git a/Sources/BaseDataTransaction.swift b/Sources/BaseDataTransaction.swift index 08879d8..59fe52f 100644 --- a/Sources/BaseDataTransaction.swift +++ b/Sources/BaseDataTransaction.swift @@ -50,7 +50,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration - returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type. */ - public func create(_ into: Into) -> D { + public func create(_ into: Into) -> O { let entityClass = into.entityClass Internals.assert( @@ -121,7 +121,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter object: the `NSManagedObject` or `CoreStoreObject` type to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public func edit(_ object: D?) -> D? { + public func edit(_ object: O?) -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -141,7 +141,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public func edit(_ into: Into, _ objectID: NSManagedObjectID) -> D? { + public func edit(_ into: Into, _ objectID: NSManagedObjectID) -> O? { Internals.assert( self.isRunningInAllowedQueue(), @@ -227,7 +227,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter object: the `DynamicObject` instance - returns: `true` if the object has any property values changed. */ - public func objectHasPersistentChangedValues(_ object: D) -> Bool { + public func objectHasPersistentChangedValues(_ object: O) -> Bool { Internals.assert( self.isRunningInAllowedQueue(), @@ -246,7 +246,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `DynamicObject`s of the specified type that were inserted to the transaction. */ - public func insertedObjects(_ entity: D.Type) -> Set { + public func insertedObjects(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), @@ -283,7 +283,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `NSManagedObjectID`s of the specified type that were inserted to the transaction. */ - public func insertedObjectIDs(_ entity: D.Type) -> Set { + public func insertedObjectIDs(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), @@ -302,7 +302,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `DynamicObject`s of the specified type that were updated in the transaction. */ - public func updatedObjects(_ entity: D.Type) -> Set { + public func updatedObjects(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), @@ -339,7 +339,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `NSManagedObjectID`s of the specified type that were updated in the transaction. */ - public func updatedObjectIDs(_ entity: D.Type) -> Set { + public func updatedObjectIDs(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), @@ -358,7 +358,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `DynamicObject`s of the specified type that were deleted from the transaction. */ - public func deletedObjects(_ entity: D.Type) -> Set { + public func deletedObjects(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), @@ -396,7 +396,7 @@ public /*abstract*/ class BaseDataTransaction { - parameter entity: the `DynamicObject` subclass to filter - returns: a `Set` of pending `NSManagedObjectID`s of the specified type that were deleted from the transaction. */ - public func deletedObjectIDs(_ entity: D.Type) -> Set { + public func deletedObjectIDs(_ entity: O.Type) -> Set { Internals.assert( self.isRunningInAllowedQueue(), diff --git a/Sources/CSFrom.swift b/Sources/CSFrom.swift index ab42aa8..ced12dd 100644 --- a/Sources/CSFrom.swift +++ b/Sources/CSFrom.swift @@ -145,7 +145,7 @@ public final class CSFrom: NSObject { public let bridgeToSwift: From - public init(_ swiftValue: From) { + public init(_ swiftValue: From) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -155,7 +155,7 @@ public final class CSFrom: NSObject { // MARK: - From -extension From where D: NSManagedObject { +extension From where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CSGroupBy.swift b/Sources/CSGroupBy.swift index 73c19dc..9a7cff9 100644 --- a/Sources/CSGroupBy.swift +++ b/Sources/CSGroupBy.swift @@ -104,7 +104,7 @@ public final class CSGroupBy: NSObject, CSQueryClause { public let bridgeToSwift: GroupBy - public init(_ swiftValue: GroupBy) { + public init(_ swiftValue: GroupBy) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -114,7 +114,7 @@ public final class CSGroupBy: NSObject, CSQueryClause { // MARK: - GroupBy -extension GroupBy where D: NSManagedObject { +extension GroupBy where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CSInto.swift b/Sources/CSInto.swift index 9c0203b..a49e602 100644 --- a/Sources/CSInto.swift +++ b/Sources/CSInto.swift @@ -112,7 +112,7 @@ public final class CSInto: NSObject { public let bridgeToSwift: Into - public required init(_ swiftValue: Into) { + public required init(_ swiftValue: Into) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -122,7 +122,7 @@ public final class CSInto: NSObject { // MARK: - Into -extension Into where D: NSManagedObject { +extension Into where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CSOrderBy.swift b/Sources/CSOrderBy.swift index cb094f8..7355596 100644 --- a/Sources/CSOrderBy.swift +++ b/Sources/CSOrderBy.swift @@ -112,7 +112,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl public let bridgeToSwift: OrderBy - public init(_ swiftValue: OrderBy) { + public init(_ swiftValue: OrderBy) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -122,7 +122,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl // MARK: - OrderBy -extension OrderBy where D: NSManagedObject { +extension OrderBy where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CSSectionBy.swift b/Sources/CSSectionBy.swift index c94cd2a..0f2751a 100644 --- a/Sources/CSSectionBy.swift +++ b/Sources/CSSectionBy.swift @@ -76,7 +76,7 @@ public final class CSSectionBy: NSObject { public let bridgeToSwift: SectionBy - public init(_ swiftValue: SectionBy) { + public init(_ swiftValue: SectionBy) { self.bridgeToSwift = swiftValue.downcast() super.init() diff --git a/Sources/CSSelect.swift b/Sources/CSSelect.swift index a73fc41..d41371f 100644 --- a/Sources/CSSelect.swift +++ b/Sources/CSSelect.swift @@ -177,7 +177,7 @@ public final class CSSelectTerm: NSObject { public let bridgeToSwift: SelectTerm - public init(_ swiftValue: SelectTerm) { + public init(_ swiftValue: SelectTerm) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -187,7 +187,7 @@ public final class CSSelectTerm: NSObject { // MARK: - SelectTerm -extension SelectTerm where D: NSManagedObject { +extension SelectTerm where O: NSManagedObject { // MARK: CoreStoreSwiftType @@ -383,7 +383,7 @@ public final class CSSelect: NSObject { // MARK: CoreStoreObjectiveCType - public init(_ swiftValue: Select) { + public init(_ swiftValue: Select) { self.attributeType = T.cs_rawAttributeType self.selectTerms = swiftValue.selectTerms.map({ $0.downcast() }) @@ -391,7 +391,7 @@ public final class CSSelect: NSObject { super.init() } - public init(_ swiftValue: Select) { + public init(_ swiftValue: Select) { self.attributeType = .undefinedAttributeType self.selectTerms = swiftValue.selectTerms.map({ $0.downcast() }) @@ -502,7 +502,7 @@ public final class CSSelect: NSObject { // MARK: - Select -extension Select where D: NSManagedObject { +extension Select where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CSWhere.swift b/Sources/CSWhere.swift index 7cb0f7c..b77aeeb 100644 --- a/Sources/CSWhere.swift +++ b/Sources/CSWhere.swift @@ -151,7 +151,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau public let bridgeToSwift: Where - public init(_ swiftValue: Where) { + public init(_ swiftValue: Where) { self.bridgeToSwift = swiftValue.downcast() super.init() @@ -161,7 +161,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau // MARK: - Where -extension Where where D: NSManagedObject { +extension Where where O: NSManagedObject { // MARK: CoreStoreSwiftType diff --git a/Sources/CoreStore+Observing.swift b/Sources/CoreStore+Observing.swift index 94fd5b7..0e0ca9c 100644 --- a/Sources/CoreStore+Observing.swift +++ b/Sources/CoreStore+Observing.swift @@ -51,7 +51,7 @@ extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public static func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { + public static func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { return CoreStoreDefaults.dataStack.monitorList(from, fetchClauses) } @@ -63,7 +63,7 @@ extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public static func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { + public static func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { return CoreStoreDefaults.dataStack.monitorList(from, fetchClauses) } @@ -92,7 +92,7 @@ extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { + public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { CoreStoreDefaults.dataStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses) } @@ -104,7 +104,7 @@ extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { + public static func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { CoreStoreDefaults.dataStack.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses) } @@ -142,7 +142,7 @@ extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { + public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { return CoreStoreDefaults.dataStack.monitorSectionedList(from, sectionBy, fetchClauses) } @@ -155,7 +155,7 @@ extension CoreStore { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { + public static func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { return CoreStoreDefaults.dataStack.monitorSectionedList(from, sectionBy, fetchClauses) } @@ -190,7 +190,7 @@ extension CoreStore { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { + public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { CoreStoreDefaults.dataStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses) } @@ -203,7 +203,7 @@ extension CoreStore { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { + public static func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { CoreStoreDefaults.dataStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses) } diff --git a/Sources/CoreStore+Querying.swift b/Sources/CoreStore+Querying.swift index 9ccb96e..bbb098a 100644 --- a/Sources/CoreStore+Querying.swift +++ b/Sources/CoreStore+Querying.swift @@ -38,7 +38,7 @@ extension CoreStore { - parameter object: a reference to the object created/fetched outside the `DataStack` - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ - public static func fetchExisting(_ object: D) -> D? { + public static func fetchExisting(_ object: O) -> O? { return CoreStoreDefaults.dataStack.fetchExisting(object) } @@ -49,7 +49,7 @@ extension CoreStore { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ - public static func fetchExisting(_ objectID: NSManagedObjectID) -> D? { + public static func fetchExisting(_ objectID: NSManagedObjectID) -> O? { return CoreStoreDefaults.dataStack.fetchExisting(objectID) } @@ -60,7 +60,7 @@ extension CoreStore { - parameter objects: an array of `DynamicObject`s created/fetched outside the `DataStack` - returns: the `DynamicObject` array for objects that exists in the `DataStack` */ - public static func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D { + public static func fetchExisting(_ objects: S) -> [O] where S.Iterator.Element == O { return CoreStoreDefaults.dataStack.fetchExisting(objects) } @@ -71,7 +71,7 @@ extension CoreStore { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `DynamicObject` array for objects that exists in the `DataStack` */ - public static func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID { + public static func fetchExisting(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID { return CoreStoreDefaults.dataStack.fetchExisting(objectIDs) } @@ -84,7 +84,7 @@ extension CoreStore { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { + public static func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> O? { return try CoreStoreDefaults.dataStack.fetchOne(from, fetchClauses) } @@ -97,7 +97,7 @@ extension CoreStore { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { + public static func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> O? { return try CoreStoreDefaults.dataStack.fetchOne(from, fetchClauses) } @@ -128,7 +128,7 @@ extension CoreStore { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { + public static func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [O] { return try CoreStoreDefaults.dataStack.fetchAll(from, fetchClauses) } @@ -141,7 +141,7 @@ extension CoreStore { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { + public static func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [O] { return try CoreStoreDefaults.dataStack.fetchAll(from, fetchClauses) } @@ -172,7 +172,7 @@ extension CoreStore { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { + public static func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { return try CoreStoreDefaults.dataStack.fetchCount(from, fetchClauses) } @@ -185,7 +185,7 @@ extension CoreStore { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { + public static func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { return try CoreStoreDefaults.dataStack.fetchCount(from, fetchClauses) } @@ -216,7 +216,7 @@ extension CoreStore { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { + public static func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { return try CoreStoreDefaults.dataStack.fetchObjectID(from, fetchClauses) } @@ -229,7 +229,7 @@ extension CoreStore { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { + public static func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { return try CoreStoreDefaults.dataStack.fetchObjectID(from, fetchClauses) } @@ -260,7 +260,7 @@ extension CoreStore { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { + public static func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { return try CoreStoreDefaults.dataStack.fetchObjectIDs(from, fetchClauses) } @@ -273,7 +273,7 @@ extension CoreStore { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { + public static func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { return try CoreStoreDefaults.dataStack.fetchObjectIDs(from, fetchClauses) } @@ -307,7 +307,7 @@ extension CoreStore { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { + public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { return try CoreStoreDefaults.dataStack.queryValue(from, selectClause, queryClauses) } @@ -323,7 +323,7 @@ extension CoreStore { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { + public static func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { return try CoreStoreDefaults.dataStack.queryValue(from, selectClause, queryClauses) } @@ -359,7 +359,7 @@ extension CoreStore { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { + public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { return try CoreStoreDefaults.dataStack.queryAttributes(from, selectClause, queryClauses) } @@ -375,7 +375,7 @@ extension CoreStore { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { + public static func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { return try CoreStoreDefaults.dataStack.queryAttributes(from, selectClause, queryClauses) } diff --git a/Sources/DataStack+DataSources.swift b/Sources/DataStack+DataSources.swift index 1b1ad43..cb3684a 100644 --- a/Sources/DataStack+DataSources.swift +++ b/Sources/DataStack+DataSources.swift @@ -51,7 +51,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListPublisher` that broadcasts changes to the fetched results */ - public func listPublisher(_ from: From, _ fetchClauses: FetchClause...) -> ListPublisher { + public func listPublisher(_ from: From, _ fetchClauses: FetchClause...) -> ListPublisher { return self.listPublisher(from, fetchClauses) } @@ -63,7 +63,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListPublisher` that broadcasts changes to the fetched results */ - public func listPublisher(_ from: From, _ fetchClauses: [FetchClause]) -> ListPublisher { + public func listPublisher(_ from: From, _ fetchClauses: [FetchClause]) -> ListPublisher { return ListPublisher( dataStack: self, @@ -75,7 +75,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListPublisher.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListPublisher.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) } ) @@ -115,7 +115,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListPublisher` that broadcasts changes to the fetched results */ - public func listPublisher(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListPublisher { + public func listPublisher(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListPublisher { return self.listPublisher( from, @@ -132,7 +132,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListPublisher` that broadcasts changes to the fetched results */ - public func listPublisher(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListPublisher { + public func listPublisher(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListPublisher { return ListPublisher( dataStack: self, @@ -144,7 +144,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListPublisher.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListPublisher.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) } ) diff --git a/Sources/DataStack+Observing.swift b/Sources/DataStack+Observing.swift index 78b4069..8c7adba 100644 --- a/Sources/DataStack+Observing.swift +++ b/Sources/DataStack+Observing.swift @@ -54,7 +54,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { + public func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorList(from, fetchClauses) } @@ -66,7 +66,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { + public func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { Internals.assert( Thread.isMainThread, @@ -82,7 +82,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) } ) @@ -115,7 +115,7 @@ extension DataStack { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { + public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { self.monitorList( createAsynchronously: createAsynchronously, @@ -131,7 +131,7 @@ extension DataStack { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { + public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { Internals.assert( Thread.isMainThread, @@ -147,7 +147,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) }, createAsynchronously: createAsynchronously @@ -187,7 +187,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { + public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorSectionedList( from, @@ -204,7 +204,7 @@ extension DataStack { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { + public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { Internals.assert( Thread.isMainThread, @@ -221,7 +221,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) } ) @@ -257,7 +257,7 @@ extension DataStack { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { + public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { self.monitorSectionedList( createAsynchronously: createAsynchronously, @@ -275,7 +275,7 @@ extension DataStack { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { + public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { Internals.assert( Thread.isMainThread, @@ -292,7 +292,7 @@ extension DataStack { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(ListMonitor.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) }, createAsynchronously: createAsynchronously diff --git a/Sources/DataStack+Querying.swift b/Sources/DataStack+Querying.swift index 3a46102..e885ee3 100644 --- a/Sources/DataStack+Querying.swift +++ b/Sources/DataStack+Querying.swift @@ -39,7 +39,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter object: a reference to the object created/fetched outside the `DataStack` - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ - public func fetchExisting(_ object: D) -> D? { + public func fetchExisting(_ object: O) -> O? { return self.mainContext.fetchExisting(object) } @@ -50,7 +50,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `DynamicObject` instance if the object exists in the `DataStack`, or `nil` if not found. */ - public func fetchExisting(_ objectID: NSManagedObjectID) -> D? { + public func fetchExisting(_ objectID: NSManagedObjectID) -> O? { return self.mainContext.fetchExisting(objectID) } @@ -61,7 +61,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter objects: an array of `DynamicObject`s created/fetched outside the `DataStack` - returns: the `DynamicObject` array for objects that exists in the `DataStack` */ - public func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D { + public func fetchExisting(_ objects: S) -> [O] where S.Iterator.Element == O { return self.mainContext.fetchExisting(objects) } @@ -72,7 +72,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `DynamicObject` array for objects that exists in the `DataStack` */ - public func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID { + public func fetchExisting(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID { return self.mainContext.fetchExisting(objectIDs) } @@ -85,7 +85,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> O? { Internals.assert( Thread.isMainThread, @@ -102,7 +102,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> O? { Internals.assert( Thread.isMainThread, @@ -141,7 +141,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [O] { Internals.assert( Thread.isMainThread, @@ -158,7 +158,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [O] { Internals.assert( Thread.isMainThread, @@ -197,7 +197,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { Internals.assert( Thread.isMainThread, @@ -214,7 +214,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { Internals.assert( Thread.isMainThread, @@ -253,7 +253,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { Internals.assert( Thread.isMainThread, @@ -270,7 +270,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { Internals.assert( Thread.isMainThread, @@ -309,7 +309,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { Internals.assert( Thread.isMainThread, @@ -326,7 +326,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { Internals.assert( Thread.isMainThread, @@ -371,7 +371,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { Internals.assert( Thread.isMainThread, @@ -391,7 +391,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { Internals.assert( Thread.isMainThread, @@ -435,7 +435,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { Internals.assert( Thread.isMainThread, @@ -455,7 +455,7 @@ extension DataStack: FetchableSource, QueryableSource { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { Internals.assert( Thread.isMainThread, diff --git a/Sources/FetchChainBuilder.swift b/Sources/FetchChainBuilder.swift index 9c30ae2..1071e08 100644 --- a/Sources/FetchChainBuilder.swift +++ b/Sources/FetchChainBuilder.swift @@ -39,14 +39,20 @@ import CoreData ) ``` */ -public struct FetchChainBuilder: FetchChainableBuilderType { +public struct FetchChainBuilder: FetchChainableBuilderType { // MARK: FetchChainableBuilderType - public typealias ObjectType = D + public typealias ObjectType = O - public var from: From + public var from: From public var fetchClauses: [FetchClause] = [] + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } diff --git a/Sources/FetchableSource.swift b/Sources/FetchableSource.swift index c2cb82c..1c9c60c 100644 --- a/Sources/FetchableSource.swift +++ b/Sources/FetchableSource.swift @@ -40,7 +40,7 @@ public protocol FetchableSource: AnyObject { - parameter object: a reference to the object created/fetched outside the `FetchableSource`'s context - returns: the `DynamicObject` instance if the object exists in the `FetchableSource`'s context, or `nil` if not found. */ - func fetchExisting(_ object: D) -> D? + func fetchExisting(_ object: O) -> O? /** Fetches the `DynamicObject` instance in the `FetchableSource`'s context from an `NSManagedObjectID`. @@ -48,7 +48,7 @@ public protocol FetchableSource: AnyObject { - parameter objectID: the `NSManagedObjectID` for the object - returns: the `DynamicObject` instance if the object exists in the `FetchableSource`, or `nil` if not found. */ - func fetchExisting(_ objectID: NSManagedObjectID) -> D? + func fetchExisting(_ objectID: NSManagedObjectID) -> O? /** Fetches the `DynamicObject` instances in the `FetchableSource`'s context from references created from another managed object context. @@ -56,7 +56,7 @@ public protocol FetchableSource: AnyObject { - parameter objects: an array of `DynamicObject`s created/fetched outside the `FetchableSource`'s context - returns: the `DynamicObject` array for objects that exists in the `FetchableSource` */ - func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D + func fetchExisting(_ objects: S) -> [O] where S.Iterator.Element == O /** Fetches the `DynamicObject` instances in the `FetchableSource`'s context from a list of `NSManagedObjectID`. @@ -64,7 +64,7 @@ public protocol FetchableSource: AnyObject { - parameter objectIDs: the `NSManagedObjectID` array for the objects - returns: the `DynamicObject` array for objects that exists in the `FetchableSource`'s context */ - func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID + func fetchExisting(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID /** Fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -74,7 +74,7 @@ public protocol FetchableSource: AnyObject { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? + func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> O? /** Fetches the first `DynamicObject` instance that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -84,7 +84,7 @@ public protocol FetchableSource: AnyObject { - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? + func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> O? /** Fetches the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses. @@ -109,7 +109,7 @@ public protocol FetchableSource: AnyObject { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] + func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [O] /** Fetches all `DynamicObject` instances that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -119,7 +119,7 @@ public protocol FetchableSource: AnyObject { - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] + func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [O] /** Fetches all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. @@ -144,7 +144,7 @@ public protocol FetchableSource: AnyObject { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int + func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int /** Fetches the number of `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -154,7 +154,7 @@ public protocol FetchableSource: AnyObject { - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int + func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int /** Fetches the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. @@ -179,7 +179,7 @@ public protocol FetchableSource: AnyObject { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? + func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? /** Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -189,7 +189,7 @@ public protocol FetchableSource: AnyObject { - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? + func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? /** Fetches the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` built from a chain of clauses. @@ -214,7 +214,7 @@ public protocol FetchableSource: AnyObject { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] + func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] /** Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s. Accepts `Where`, `OrderBy`, and `Tweak` clauses. @@ -224,7 +224,7 @@ public protocol FetchableSource: AnyObject { - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] + func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] /** Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses. diff --git a/Sources/From+Querying.swift b/Sources/From+Querying.swift index ad89e3c..82ee3e1 100644 --- a/Sources/From+Querying.swift +++ b/Sources/From+Querying.swift @@ -37,7 +37,7 @@ extension From { - parameter clause: the `Where` clause to create a `FetchChainBuilder` with - returns: a `FetchChainBuilder` that starts with the specified `Where` clause */ - public func `where`(_ clause: Where) -> FetchChainBuilder { + public func `where`(_ clause: Where) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -49,9 +49,9 @@ extension From { - parameter args: the arguments for `format` - returns: a `FetchChainBuilder` with a predicate using the specified string format and arguments */ - public func `where`(format: String, _ args: Any...) -> FetchChainBuilder { + public func `where`(format: String, _ args: Any...) -> FetchChainBuilder { - return self.fetchChain(appending: Where(format, argumentArray: args)) + return self.fetchChain(appending: Where(format, argumentArray: args)) } /** @@ -61,9 +61,9 @@ extension From { - parameter argumentArray: the arguments for `format` - returns: a `FetchChainBuilder` with a predicate using the specified string format and arguments */ - public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder { + public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder { - return self.fetchChain(appending: Where(format, argumentArray: argumentArray)) + return self.fetchChain(appending: Where(format, argumentArray: argumentArray)) } /** @@ -72,7 +72,7 @@ extension From { - parameter clause: the `OrderBy` clause to create a `FetchChainBuilder` with - returns: a `FetchChainBuilder` that starts with the specified `OrderBy` clause */ - public func orderBy(_ clause: OrderBy) -> FetchChainBuilder { + public func orderBy(_ clause: OrderBy) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -84,9 +84,9 @@ extension From { - parameter sortKeys: a series of other `SortKey`s - returns: a `FetchChainBuilder` with a series of `SortKey`s */ - public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> FetchChainBuilder { + public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> FetchChainBuilder { - return self.fetchChain(appending: OrderBy([sortKey] + sortKeys)) + return self.fetchChain(appending: OrderBy([sortKey] + sortKeys)) } /** @@ -95,9 +95,9 @@ extension From { - parameter sortKeys: a series of `SortKey`s - returns: a `FetchChainBuilder` with a series of `SortKey`s */ - public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> FetchChainBuilder { + public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> FetchChainBuilder { - return self.fetchChain(appending: OrderBy(sortKeys)) + return self.fetchChain(appending: OrderBy(sortKeys)) } /** @@ -106,7 +106,7 @@ extension From { - parameter fetchRequest: the block to customize the `NSFetchRequest` - returns: a `FetchChainBuilder` with closure where the `NSFetchRequest` may be configured */ - public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> FetchChainBuilder { + public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> FetchChainBuilder { return self.fetchChain(appending: Tweak(fetchRequest)) } @@ -117,7 +117,7 @@ extension From { - parameter clause: the `FetchClause` to add to the `FetchChainBuilder` - returns: a `FetchChainBuilder` containing the specified `FetchClause` */ - public func appending(_ clause: FetchClause) -> FetchChainBuilder { + public func appending(_ clause: FetchClause) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -128,7 +128,7 @@ extension From { - parameter clauses: the `FetchClause`s to add to the `FetchChainBuilder` - returns: a `FetchChainBuilder` containing the specified `FetchClause`s */ - public func appending(contentsOf clauses: S) -> FetchChainBuilder where S.Element == FetchClause { + public func appending(contentsOf clauses: S) -> FetchChainBuilder where S.Element == FetchClause { return self.fetchChain(appending: clauses) } @@ -139,7 +139,7 @@ extension From { - parameter clause: the `Select` clause to create a `QueryChainBuilder` with - returns: a `QueryChainBuilder` that starts with the specified `Select` clause */ - public func select(_ clause: Select) -> QueryChainBuilder { + public func select(_ clause: Select) -> QueryChainBuilder { return .init( from: self, @@ -156,7 +156,7 @@ extension From { - parameter selectTerms: a series of `SelectTerm`s - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified `SelectTerm`s */ - public func select(_ resultType: R.Type, _ selectTerm: SelectTerm, _ selectTerms: SelectTerm...) -> QueryChainBuilder { + public func select(_ resultType: R.Type, _ selectTerm: SelectTerm, _ selectTerms: SelectTerm...) -> QueryChainBuilder { return self.select(resultType, [selectTerm] + selectTerms) } @@ -168,7 +168,7 @@ extension From { - parameter selectTerms: a series of `SelectTerm`s - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified `SelectTerm`s */ - public func select(_ resultType: R.Type, _ selectTerms: [SelectTerm]) -> QueryChainBuilder { + public func select(_ resultType: R.Type, _ selectTerms: [SelectTerm]) -> QueryChainBuilder { return .init( from: self, @@ -184,7 +184,7 @@ extension From { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ clause: SectionBy) -> SectionMonitorChainBuilder { + public func sectionBy(_ clause: SectionBy) -> SectionMonitorChainBuilder { return .init( from: self, @@ -200,7 +200,7 @@ extension From { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder { return self.sectionBy(sectionKeyPath, { $0 }) } @@ -214,7 +214,7 @@ extension From { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { return .init( from: self, @@ -226,21 +226,21 @@ extension From { // MARK: Private - private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder { + private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder { return .init(from: self, fetchClauses: [clause]) } - private func fetchChain(appending clauses: S) -> FetchChainBuilder where S.Element == FetchClause { + private func fetchChain(appending clauses: S) -> FetchChainBuilder where S.Element == FetchClause { return .init(from: self, fetchClauses: Array(clauses)) } } -// MARK: - From where D: NSManagedObject +// MARK: - From where O: NSManagedObject -extension From where D: NSManagedObject { +extension From where O: NSManagedObject { /** Creates a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path @@ -248,9 +248,9 @@ extension From where D: NSManagedObject { - parameter keyPath: the keyPath to query the value for - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path */ - public func select(_ keyPath: KeyPath) -> QueryChainBuilder { + public func select(_ keyPath: KeyPath) -> QueryChainBuilder { - return self.select(R.self, [SelectTerm.attribute(keyPath)]) + return self.select(R.self, [SelectTerm.attribute(keyPath)]) } /** @@ -260,7 +260,7 @@ extension From where D: NSManagedObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath) -> SectionMonitorChainBuilder { return self.sectionBy(sectionKeyPath._kvcKeyPathString!, { $0 }) } @@ -274,16 +274,16 @@ extension From where D: NSManagedObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { return self.sectionBy(sectionKeyPath._kvcKeyPathString!, sectionIndexTransformer) } } -// MARK: - From where D: CoreStoreObject +// MARK: - From where O: CoreStoreObject -extension From where D: CoreStoreObject { +extension From where O: CoreStoreObject { /** Creates a `FetchChainBuilder` that starts with the specified `Where` clause @@ -291,12 +291,12 @@ extension From where D: CoreStoreObject { - parameter clause: a closure that returns a `Where` clause - returns: a `FetchChainBuilder` that starts with the specified `Where` clause */ - public func `where`(_ clause: (D) -> T) -> FetchChainBuilder { + public func `where`(_ clause: (O) -> T) -> FetchChainBuilder { - return self.fetchChain(appending: clause(D.meta)) + return self.fetchChain(appending: clause(O.meta)) } - public func `where`(combinedByAnd clause: Where, _ others: Where...) -> FetchChainBuilder { + public func `where`(combinedByAnd clause: Where, _ others: Where...) -> FetchChainBuilder { return self.fetchChain(appending: ([clause] + others).combinedByAnd()) } @@ -307,9 +307,9 @@ extension From where D: CoreStoreObject { - parameter keyPath: the keyPath to query the value for - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path */ - public func select(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { + public func select(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { - return self.select(R.self, [SelectTerm.attribute(keyPath)]) + return self.select(R.self, [SelectTerm.attribute(keyPath)]) } /** @@ -318,9 +318,9 @@ extension From where D: CoreStoreObject { - parameter keyPath: the keyPath to query the value for - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path */ - public func select(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { + public func select(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { - return self.select(R.self, [SelectTerm.attribute(keyPath)]) + return self.select(R.self, [SelectTerm.attribute(keyPath)]) } /** @@ -329,9 +329,9 @@ extension From where D: CoreStoreObject { - parameter keyPath: the keyPath to query the value for - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path */ - public func select(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { + public func select(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { - return self.select(R.self, [SelectTerm.attribute(keyPath)]) + return self.select(R.self, [SelectTerm.attribute(keyPath)]) } /** @@ -340,9 +340,9 @@ extension From where D: CoreStoreObject { - parameter keyPath: the keyPath to query the value for - returns: a `QueryChainBuilder` that starts with a `Select` clause created from the specified key path */ - public func select(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { + public func select(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { - return self.select(R.self, [SelectTerm.attribute(keyPath)]) + return self.select(R.self, [SelectTerm.attribute(keyPath)]) } /** @@ -352,9 +352,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Required>) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Required>) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, { $0 }) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, { $0 }) } /** @@ -364,9 +364,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Optional>) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Optional>) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, { $0 }) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, { $0 }) } /** @@ -376,9 +376,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Required>) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Required>) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, { $0 }) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, { $0 }) } /** @@ -388,9 +388,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Optional>) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Optional>) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, { $0 }) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, { $0 }) } /** @@ -402,9 +402,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -416,9 +416,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -430,9 +430,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -444,9 +444,9 @@ extension From where D: CoreStoreObject { - returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path */ @available(macOS 10.12, *) - public func sectionBy(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { + public func sectionBy(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder { - return self.sectionBy(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + return self.sectionBy(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } } @@ -461,7 +461,7 @@ extension FetchChainBuilder { - parameter clause: a `Where` clause to add to the fetch builder - returns: a new `FetchChainBuilder` containing the `Where` clause */ - public func `where`(_ clause: Where) -> FetchChainBuilder { + public func `where`(_ clause: Where) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -473,9 +473,9 @@ extension FetchChainBuilder { - parameter args: the arguments for `format` - returns: a new `FetchChainBuilder` containing the `Where` clause */ - public func `where`(format: String, _ args: Any...) -> FetchChainBuilder { + public func `where`(format: String, _ args: Any...) -> FetchChainBuilder { - return self.fetchChain(appending: Where(format, argumentArray: args)) + return self.fetchChain(appending: Where(format, argumentArray: args)) } /** @@ -485,9 +485,9 @@ extension FetchChainBuilder { - parameter argumentArray: the arguments for `format` - returns: a new `FetchChainBuilder` containing the `Where` clause */ - public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder { + public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder { - return self.fetchChain(appending: Where(format, argumentArray: argumentArray)) + return self.fetchChain(appending: Where(format, argumentArray: argumentArray)) } /** @@ -496,7 +496,7 @@ extension FetchChainBuilder { - parameter clause: the `OrderBy` clause to add - returns: a new `FetchChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ clause: OrderBy) -> FetchChainBuilder { + public func orderBy(_ clause: OrderBy) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -508,9 +508,9 @@ extension FetchChainBuilder { - parameter sortKeys: a series of other `SortKey`s - returns: a new `FetchChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> FetchChainBuilder { + public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> FetchChainBuilder { - return self.fetchChain(appending: OrderBy([sortKey] + sortKeys)) + return self.fetchChain(appending: OrderBy([sortKey] + sortKeys)) } /** @@ -519,9 +519,9 @@ extension FetchChainBuilder { - parameter sortKeys: a series of `SortKey`s - returns: a new `FetchChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> FetchChainBuilder { + public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> FetchChainBuilder { - return self.fetchChain(appending: OrderBy(sortKeys)) + return self.fetchChain(appending: OrderBy(sortKeys)) } /** @@ -530,7 +530,7 @@ extension FetchChainBuilder { - parameter fetchRequest: the block to customize the `NSFetchRequest` - returns: a new `FetchChainBuilder` containing the `Tweak` clause */ - public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> FetchChainBuilder { + public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> FetchChainBuilder { return self.fetchChain(appending: Tweak(fetchRequest)) } @@ -541,7 +541,7 @@ extension FetchChainBuilder { - parameter clause: the `FetchClause` to add to the `FetchChainBuilder` - returns: a new `FetchChainBuilder` containing the `FetchClause` */ - public func appending(_ clause: FetchClause) -> FetchChainBuilder { + public func appending(_ clause: FetchClause) -> FetchChainBuilder { return self.fetchChain(appending: clause) } @@ -552,7 +552,7 @@ extension FetchChainBuilder { - parameter clauses: the `FetchClause`s to add to the `FetchChainBuilder` - returns: a new `FetchChainBuilder` containing the `FetchClause`s */ - public func appending(contentsOf clauses: S) -> FetchChainBuilder where S.Element == FetchClause { + public func appending(contentsOf clauses: S) -> FetchChainBuilder where S.Element == FetchClause { return self.fetchChain(appending: clauses) } @@ -560,7 +560,7 @@ extension FetchChainBuilder { // MARK: Private - private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder { + private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder { return .init( from: self.from, @@ -568,7 +568,7 @@ extension FetchChainBuilder { ) } - private func fetchChain(appending clauses: S) -> FetchChainBuilder where S.Element == FetchClause { + private func fetchChain(appending clauses: S) -> FetchChainBuilder where S.Element == FetchClause { return .init( from: self.from, @@ -578,13 +578,13 @@ extension FetchChainBuilder { } -// MARK: - FetchChainBuilder where D: CoreStoreObject +// MARK: - FetchChainBuilder where O: CoreStoreObject -extension FetchChainBuilder where D: CoreStoreObject { +extension FetchChainBuilder where O: CoreStoreObject { - public func `where`(_ clause: (D) -> T) -> FetchChainBuilder { + public func `where`(_ clause: (O) -> T) -> FetchChainBuilder { - return self.fetchChain(appending: clause(D.meta)) + return self.fetchChain(appending: clause(O.meta)) } } @@ -599,7 +599,7 @@ extension QueryChainBuilder { - parameter clause: a `Where` clause to add to the query builder - returns: a new `QueryChainBuilder` containing the `Where` clause */ - public func `where`(_ clause: Where) -> QueryChainBuilder { + public func `where`(_ clause: Where) -> QueryChainBuilder { return self.queryChain(appending: clause) } @@ -611,9 +611,9 @@ extension QueryChainBuilder { - parameter args: the arguments for `format` - returns: a new `QueryChainBuilder` containing the `Where` clause */ - public func `where`(format: String, _ args: Any...) -> QueryChainBuilder { + public func `where`(format: String, _ args: Any...) -> QueryChainBuilder { - return self.queryChain(appending: Where(format, argumentArray: args)) + return self.queryChain(appending: Where(format, argumentArray: args)) } /** @@ -623,9 +623,9 @@ extension QueryChainBuilder { - parameter argumentArray: the arguments for `format` - returns: a new `QueryChainBuilder` containing the `Where` clause */ - public func `where`(format: String, argumentArray: [Any]?) -> QueryChainBuilder { + public func `where`(format: String, argumentArray: [Any]?) -> QueryChainBuilder { - return self.queryChain(appending: Where(format, argumentArray: argumentArray)) + return self.queryChain(appending: Where(format, argumentArray: argumentArray)) } /** @@ -634,7 +634,7 @@ extension QueryChainBuilder { - parameter clause: the `OrderBy` clause to add - returns: a new `QueryChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ clause: OrderBy) -> QueryChainBuilder { + public func orderBy(_ clause: OrderBy) -> QueryChainBuilder { return self.queryChain(appending: clause) } @@ -646,9 +646,9 @@ extension QueryChainBuilder { - parameter sortKeys: a series of other `SortKey`s - returns: a new `QueryChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> QueryChainBuilder { + public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> QueryChainBuilder { - return self.queryChain(appending: OrderBy([sortKey] + sortKeys)) + return self.queryChain(appending: OrderBy([sortKey] + sortKeys)) } /** @@ -657,9 +657,9 @@ extension QueryChainBuilder { - parameter sortKeys: a series of `SortKey`s - returns: a new `QueryChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> QueryChainBuilder { + public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> QueryChainBuilder { - return self.queryChain(appending: OrderBy(sortKeys)) + return self.queryChain(appending: OrderBy(sortKeys)) } /** @@ -668,7 +668,7 @@ extension QueryChainBuilder { - parameter fetchRequest: the block to customize the `NSFetchRequest` - returns: a new `QueryChainBuilder` containing the `Tweak` clause */ - public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> QueryChainBuilder { + public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> QueryChainBuilder { return self.queryChain(appending: Tweak(fetchRequest)) } @@ -679,7 +679,7 @@ extension QueryChainBuilder { - parameter clause: a `GroupBy` clause to add to the query builder - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ clause: GroupBy) -> QueryChainBuilder { + public func groupBy(_ clause: GroupBy) -> QueryChainBuilder { return self.queryChain(appending: clause) } @@ -691,9 +691,9 @@ extension QueryChainBuilder { - parameter keyPaths: other key paths to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPathString, _ keyPaths: KeyPathString...) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPathString, _ keyPaths: KeyPathString...) -> QueryChainBuilder { - return self.groupBy(GroupBy([keyPath] + keyPaths)) + return self.groupBy(GroupBy([keyPath] + keyPaths)) } /** @@ -702,9 +702,9 @@ extension QueryChainBuilder { - parameter keyPaths: a series of key paths to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPaths: [KeyPathString]) -> QueryChainBuilder { + public func groupBy(_ keyPaths: [KeyPathString]) -> QueryChainBuilder { - return self.queryChain(appending: GroupBy(keyPaths)) + return self.queryChain(appending: GroupBy(keyPaths)) } /** @@ -713,7 +713,7 @@ extension QueryChainBuilder { - parameter clause: the `QueryClause` to add to the `QueryChainBuilder` - returns: a new `QueryChainBuilder` containing the `QueryClause` */ - public func appending(_ clause: QueryClause) -> QueryChainBuilder { + public func appending(_ clause: QueryClause) -> QueryChainBuilder { return self.queryChain(appending: clause) } @@ -724,7 +724,7 @@ extension QueryChainBuilder { - parameter clauses: the `QueryClause`s to add to the `QueryChainBuilder` - returns: a new `QueryChainBuilder` containing the `QueryClause`s */ - public func appending(contentsOf clauses: S) -> QueryChainBuilder where S.Element == QueryClause { + public func appending(contentsOf clauses: S) -> QueryChainBuilder where S.Element == QueryClause { return self.queryChain(appending: clauses) } @@ -732,7 +732,7 @@ extension QueryChainBuilder { // MARK: Private - private func queryChain(appending clause: QueryClause) -> QueryChainBuilder { + private func queryChain(appending clause: QueryClause) -> QueryChainBuilder { return .init( from: self.from, @@ -741,7 +741,7 @@ extension QueryChainBuilder { ) } - private func queryChain(appending clauses: S) -> QueryChainBuilder where S.Element == QueryClause { + private func queryChain(appending clauses: S) -> QueryChainBuilder where S.Element == QueryClause { return .init( from: self.from, @@ -752,9 +752,9 @@ extension QueryChainBuilder { } -// MARK: - QueryChainBuilder where D: NSManagedObject +// MARK: - QueryChainBuilder where O: NSManagedObject -extension QueryChainBuilder where D: NSManagedObject { +extension QueryChainBuilder where O: NSManagedObject { /** Adds a `GroupBy` clause to the `QueryChainBuilder` @@ -762,16 +762,16 @@ extension QueryChainBuilder where D: NSManagedObject { - parameter keyPath: a key path to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPath) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPath) -> QueryChainBuilder { - return self.groupBy(GroupBy(keyPath)) + return self.groupBy(GroupBy(keyPath)) } } -// MARK: - QueryChainBuilder where D: CoreStoreObject +// MARK: - QueryChainBuilder where O: CoreStoreObject -extension QueryChainBuilder where D: CoreStoreObject { +extension QueryChainBuilder where O: CoreStoreObject { /** Adds a `Where` clause to the `QueryChainBuilder` @@ -779,9 +779,9 @@ extension QueryChainBuilder where D: CoreStoreObject { - parameter clause: a `Where` clause to add to the query builder - returns: a new `QueryChainBuilder` containing the `Where` clause */ - public func `where`(_ clause: (D) -> T) -> QueryChainBuilder { + public func `where`(_ clause: (O) -> T) -> QueryChainBuilder { - return self.queryChain(appending: clause(D.meta)) + return self.queryChain(appending: clause(O.meta)) } /** @@ -790,9 +790,9 @@ extension QueryChainBuilder where D: CoreStoreObject { - parameter keyPath: a key path to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { - return self.groupBy(GroupBy(keyPath)) + return self.groupBy(GroupBy(keyPath)) } /** @@ -801,9 +801,9 @@ extension QueryChainBuilder where D: CoreStoreObject { - parameter keyPath: a key path to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { - return self.groupBy(GroupBy(keyPath)) + return self.groupBy(GroupBy(keyPath)) } /** @@ -812,9 +812,9 @@ extension QueryChainBuilder where D: CoreStoreObject { - parameter keyPath: a key path to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPath.Required>) -> QueryChainBuilder { - return self.groupBy(GroupBy(keyPath)) + return self.groupBy(GroupBy(keyPath)) } /** @@ -823,9 +823,9 @@ extension QueryChainBuilder where D: CoreStoreObject { - parameter keyPath: a key path to group the query results with - returns: a new `QueryChainBuilder` containing the `GroupBy` clause */ - public func groupBy(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { + public func groupBy(_ keyPath: KeyPath.Optional>) -> QueryChainBuilder { - return self.groupBy(GroupBy(keyPath)) + return self.groupBy(GroupBy(keyPath)) } } @@ -841,7 +841,7 @@ extension SectionMonitorChainBuilder { - parameter clause: a `Where` clause to add to the fetch builder - returns: a new `SectionMonitorChainBuilder` containing the `Where` clause */ - public func `where`(_ clause: Where) -> SectionMonitorChainBuilder { + public func `where`(_ clause: Where) -> SectionMonitorChainBuilder { return self.sectionMonitorChain(appending: clause) } @@ -853,9 +853,9 @@ extension SectionMonitorChainBuilder { - parameter args: the arguments for `format` - returns: a new `SectionMonitorChainBuilder` containing the `Where` clause */ - public func `where`(format: String, _ args: Any...) -> SectionMonitorChainBuilder { + public func `where`(format: String, _ args: Any...) -> SectionMonitorChainBuilder { - return self.sectionMonitorChain(appending: Where(format, argumentArray: args)) + return self.sectionMonitorChain(appending: Where(format, argumentArray: args)) } /** @@ -865,9 +865,9 @@ extension SectionMonitorChainBuilder { - parameter argumentArray: the arguments for `format` - returns: a new `SectionMonitorChainBuilder` containing the `Where` clause */ - public func `where`(format: String, argumentArray: [Any]?) -> SectionMonitorChainBuilder { + public func `where`(format: String, argumentArray: [Any]?) -> SectionMonitorChainBuilder { - return self.sectionMonitorChain(appending: Where(format, argumentArray: argumentArray)) + return self.sectionMonitorChain(appending: Where(format, argumentArray: argumentArray)) } /** @@ -876,7 +876,7 @@ extension SectionMonitorChainBuilder { - parameter clause: the `OrderBy` clause to add - returns: a new `SectionMonitorChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ clause: OrderBy) -> SectionMonitorChainBuilder { + public func orderBy(_ clause: OrderBy) -> SectionMonitorChainBuilder { return self.sectionMonitorChain(appending: clause) } @@ -888,9 +888,9 @@ extension SectionMonitorChainBuilder { - parameter sortKeys: a series of other `SortKey`s - returns: a new `SectionMonitorChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> SectionMonitorChainBuilder { + public func orderBy(_ sortKey: OrderBy.SortKey, _ sortKeys: OrderBy.SortKey...) -> SectionMonitorChainBuilder { - return self.sectionMonitorChain(appending: OrderBy([sortKey] + sortKeys)) + return self.sectionMonitorChain(appending: OrderBy([sortKey] + sortKeys)) } /** @@ -899,9 +899,9 @@ extension SectionMonitorChainBuilder { - parameter sortKeys: a series of `SortKey`s - returns: a new `SectionMonitorChainBuilder` containing the `OrderBy` clause */ - public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> SectionMonitorChainBuilder { + public func orderBy(_ sortKeys: [OrderBy.SortKey]) -> SectionMonitorChainBuilder { - return self.sectionMonitorChain(appending: OrderBy(sortKeys)) + return self.sectionMonitorChain(appending: OrderBy(sortKeys)) } /** @@ -910,7 +910,7 @@ extension SectionMonitorChainBuilder { - parameter fetchRequest: the block to customize the `NSFetchRequest` - returns: a new `SectionMonitorChainBuilder` containing the `Tweak` clause */ - public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> SectionMonitorChainBuilder { + public func tweak(_ fetchRequest: @escaping (NSFetchRequest) -> Void) -> SectionMonitorChainBuilder { return self.sectionMonitorChain(appending: Tweak(fetchRequest)) } @@ -921,7 +921,7 @@ extension SectionMonitorChainBuilder { - parameter clause: the `QueryClause` to add to the `SectionMonitorChainBuilder` - returns: a new `SectionMonitorChainBuilder` containing the `QueryClause` */ - public func appending(_ clause: FetchClause) -> SectionMonitorChainBuilder { + public func appending(_ clause: FetchClause) -> SectionMonitorChainBuilder { return self.sectionMonitorChain(appending: clause) } @@ -932,7 +932,7 @@ extension SectionMonitorChainBuilder { - parameter clauses: the `QueryClause`s to add to the `SectionMonitorChainBuilder` - returns: a new `SectionMonitorChainBuilder` containing the `QueryClause`s */ - public func appending(contentsOf clauses: S) -> SectionMonitorChainBuilder where S.Element == FetchClause { + public func appending(contentsOf clauses: S) -> SectionMonitorChainBuilder where S.Element == FetchClause { return self.sectionMonitorChain(appending: clauses) } @@ -940,7 +940,7 @@ extension SectionMonitorChainBuilder { // MARK: Private - private func sectionMonitorChain(appending clause: FetchClause) -> SectionMonitorChainBuilder { + private func sectionMonitorChain(appending clause: FetchClause) -> SectionMonitorChainBuilder { return .init( from: self.from, @@ -949,7 +949,7 @@ extension SectionMonitorChainBuilder { ) } - private func sectionMonitorChain(appending clauses: S) -> SectionMonitorChainBuilder where S.Element == FetchClause { + private func sectionMonitorChain(appending clauses: S) -> SectionMonitorChainBuilder where S.Element == FetchClause { return .init( from: self.from, @@ -960,10 +960,10 @@ extension SectionMonitorChainBuilder { } -// MARK: - SectionMonitorChainBuilder where D: CoreStoreObject +// MARK: - SectionMonitorChainBuilder where O: CoreStoreObject @available(macOS 10.12, *) -extension SectionMonitorChainBuilder where D: CoreStoreObject { +extension SectionMonitorChainBuilder where O: CoreStoreObject { /** Adds a `Where` clause to the `SectionMonitorChainBuilder` @@ -971,8 +971,8 @@ extension SectionMonitorChainBuilder where D: CoreStoreObject { - parameter clause: a `Where` clause to add to the fetch builder - returns: a new `SectionMonitorChainBuilder` containing the `Where` clause */ - public func `where`(_ clause: (D) -> T) -> SectionMonitorChainBuilder { + public func `where`(_ clause: (O) -> T) -> SectionMonitorChainBuilder { - return self.sectionMonitorChain(appending: clause(D.meta)) + return self.sectionMonitorChain(appending: clause(O.meta)) } } diff --git a/Sources/From.swift b/Sources/From.swift index 5eaaa35..c12bbef 100644 --- a/Sources/From.swift +++ b/Sources/From.swift @@ -39,12 +39,12 @@ import CoreData let person = transaction.fetchOne(From("Configuration1")) ``` */ -public struct From { +public struct From { /** The associated `NSManagedObject` or `CoreStoreObject` entity class */ - public let entityClass: D.Type + public let entityClass: O.Type /** The `NSPersistentStore` configuration names to associate objects from. @@ -60,7 +60,7 @@ public struct From { */ public init() { - self.init(entityClass: D.self, configurations: nil) + self.init(entityClass: O.self, configurations: nil) } /** @@ -70,7 +70,7 @@ public struct From { ``` - parameter entity: the associated `NSManagedObject` or `CoreStoreObject` type */ - public init(_ entity: D.Type) { + public init(_ entity: O.Type) { self.init(entityClass: entity, configurations: nil) } @@ -85,7 +85,7 @@ public struct From { */ public init(_ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) { - self.init(entityClass: D.self, configurations: [configuration] + otherConfigurations) + self.init(entityClass: O.self, configurations: [configuration] + otherConfigurations) } /** @@ -97,7 +97,7 @@ public struct From { */ public init(_ configurations: [ModelConfiguration]) { - self.init(entityClass: D.self, configurations: configurations) + self.init(entityClass: O.self, configurations: configurations) } /** @@ -109,7 +109,7 @@ public struct From { - parameter configuration: the `NSPersistentStore` configuration name to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration. - parameter otherConfigurations: an optional list of other configuration names to associate objects from (see `configuration` parameter) */ - public init(_ entity: D.Type, _ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) { + public init(_ entity: O.Type, _ configuration: ModelConfiguration, _ otherConfigurations: ModelConfiguration...) { self.init(entityClass: entity, configurations: [configuration] + otherConfigurations) } @@ -122,7 +122,7 @@ public struct From { - parameter entity: the associated `NSManagedObject` or `CoreStoreObject` type - parameter configurations: a list of `NSPersistentStore` configuration names to associate objects from. This parameter is required if multiple configurations contain the created `NSManagedObject` or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration. */ - public init(_ entity: D.Type, _ configurations: [ModelConfiguration]) { + public init(_ entity: O.Type, _ configurations: [ModelConfiguration]) { self.init(entityClass: entity, configurations: configurations) } @@ -132,7 +132,7 @@ public struct From { internal let findPersistentStores: (_ context: NSManagedObjectContext) -> [NSPersistentStore]? - internal init(entityClass: D.Type, configurations: [ModelConfiguration]?, findPersistentStores: @escaping (_ context: NSManagedObjectContext) -> [NSPersistentStore]?) { + internal init(entityClass: O.Type, configurations: [ModelConfiguration]?, findPersistentStores: @escaping (_ context: NSManagedObjectContext) -> [NSPersistentStore]?) { self.entityClass = entityClass self.configurations = configurations @@ -186,7 +186,7 @@ public struct From { // MARK: Private - private init(entityClass: D.Type, configurations: [ModelConfiguration]?) { + private init(entityClass: O.Type, configurations: [ModelConfiguration]?) { self.entityClass = entityClass self.configurations = configurations @@ -211,4 +211,10 @@ public struct From { } } } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } diff --git a/Sources/GroupBy.swift b/Sources/GroupBy.swift index a4750e1..4b80a2b 100644 --- a/Sources/GroupBy.swift +++ b/Sources/GroupBy.swift @@ -32,7 +32,7 @@ import CoreData /** The `GroupBy` clause specifies that the result of a query be grouped accoording to the specified key path. */ -public struct GroupBy: GroupByClause, QueryClause, Hashable { +public struct GroupBy: GroupByClause, QueryClause, Hashable { /** Initializes a `GroupBy` clause with an empty list of key path strings @@ -66,7 +66,7 @@ public struct GroupBy: GroupByClause, QueryClause, Hashable { // MARK: GroupByClause - public typealias ObjectType = D + public typealias ObjectType = O public let keyPaths: [KeyPathString] @@ -101,31 +101,37 @@ public struct GroupBy: GroupByClause, QueryClause, Hashable { hasher.combine(self.keyPaths) } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } -extension GroupBy where D: NSManagedObject { +extension GroupBy where O: NSManagedObject { /** Initializes a `GroupBy` clause with a key path - parameter keyPath: a key path to group results with */ - public init(_ keyPath: KeyPath) { + public init(_ keyPath: KeyPath) { self.init([keyPath._kvcKeyPathString!]) } } -extension GroupBy where D: CoreStoreObject { +extension GroupBy where O: CoreStoreObject { /** Initializes a `GroupBy` clause with a key path - parameter keyPath: a key path to group results with */ - public init(_ keyPath: KeyPath.Required>) { + public init(_ keyPath: KeyPath.Required>) { - self.init([D.meta[keyPath: keyPath].keyPath]) + self.init([O.meta[keyPath: keyPath].keyPath]) } /** @@ -133,9 +139,9 @@ extension GroupBy where D: CoreStoreObject { - parameter keyPath: a key path to group results with */ - public init(_ keyPath: KeyPath.Optional>) { + public init(_ keyPath: KeyPath.Optional>) { - self.init([D.meta[keyPath: keyPath].keyPath]) + self.init([O.meta[keyPath: keyPath].keyPath]) } /** @@ -143,9 +149,9 @@ extension GroupBy where D: CoreStoreObject { - parameter keyPath: a key path to group results with */ - public init(_ keyPath: KeyPath.Required>) { + public init(_ keyPath: KeyPath.Required>) { - self.init([D.meta[keyPath: keyPath].keyPath]) + self.init([O.meta[keyPath: keyPath].keyPath]) } /** @@ -153,9 +159,9 @@ extension GroupBy where D: CoreStoreObject { - parameter keyPath: a key path to group results with */ - public init(_ keyPath: KeyPath.Optional>) { + public init(_ keyPath: KeyPath.Optional>) { - self.init([D.meta[keyPath: keyPath].keyPath]) + self.init([O.meta[keyPath: keyPath].keyPath]) } } diff --git a/Sources/Internals.CoreStoreFetchedResultsController.swift b/Sources/Internals.CoreStoreFetchedResultsController.swift index e27bf45..699b7db 100644 --- a/Sources/Internals.CoreStoreFetchedResultsController.swift +++ b/Sources/Internals.CoreStoreFetchedResultsController.swift @@ -42,7 +42,7 @@ extension Internals { internal let typedFetchRequest: Internals.CoreStoreFetchRequest @nonobjc - internal convenience init(dataStack: DataStack, fetchRequest: Internals.CoreStoreFetchRequest, from: From, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest) -> Void) { + internal convenience init(dataStack: DataStack, fetchRequest: Internals.CoreStoreFetchRequest, from: From, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest) -> Void) { self.init( context: dataStack.mainContext, @@ -54,7 +54,7 @@ extension Internals { } @nonobjc - internal init(context: NSManagedObjectContext, fetchRequest: Internals.CoreStoreFetchRequest, from: From, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest) -> Void) { + internal init(context: NSManagedObjectContext, fetchRequest: Internals.CoreStoreFetchRequest, from: From, sectionBy: SectionBy? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest) -> Void) { _ = try? from.applyToFetchRequest( fetchRequest, diff --git a/Sources/Into.swift b/Sources/Into.swift index a2fa9ec..73c8705 100644 --- a/Sources/Into.swift +++ b/Sources/Into.swift @@ -39,12 +39,12 @@ import CoreData let person = transaction.create(Into("Configuration1")) ``` */ -public struct Into: Hashable { +public struct Into: Hashable { /** The associated `NSManagedObject` or `CoreStoreObject` entity class */ - public let entityClass: D.Type + public let entityClass: O.Type /** The `NSPersistentStore` configuration name to associate objects from. @@ -60,7 +60,7 @@ public struct Into: Hashable { */ public init() { - self.init(entityClass: D.self, configuration: nil, inferStoreIfPossible: true) + self.init(entityClass: O.self, configuration: nil, inferStoreIfPossible: true) } /** @@ -70,7 +70,7 @@ public struct Into: Hashable { ``` - parameter entity: the `NSManagedObject` or `CoreStoreObject` type to be created */ - public init(_ entity: D.Type) { + public init(_ entity: O.Type) { self.init(entityClass: entity, configuration: nil, inferStoreIfPossible: true) } @@ -84,7 +84,7 @@ public struct Into: Hashable { */ public init(_ configuration: ModelConfiguration) { - self.init(entityClass: D.self, configuration: configuration, inferStoreIfPossible: false) + self.init(entityClass: O.self, configuration: configuration, inferStoreIfPossible: false) } /** @@ -95,7 +95,7 @@ public struct Into: Hashable { - parameter entity: the `NSManagedObject` or `CoreStoreObject` type to be created - parameter configuration: the `NSPersistentStore` configuration name to associate the object to. This parameter is required if multiple configurations contain the created `NSManagedObject`'s or `CoreStoreObject`'s entity type. Set to `nil` to use the default configuration. */ - public init(_ entity: D.Type, _ configuration: ModelConfiguration) { + public init(_ entity: O.Type, _ configuration: ModelConfiguration) { self.init(entityClass: entity, configuration: configuration, inferStoreIfPossible: false) } @@ -125,10 +125,16 @@ public struct Into: Hashable { internal let inferStoreIfPossible: Bool - internal init(entityClass: D.Type, configuration: ModelConfiguration, inferStoreIfPossible: Bool) { + internal init(entityClass: O.Type, configuration: ModelConfiguration, inferStoreIfPossible: Bool) { self.entityClass = entityClass self.configuration = configuration self.inferStoreIfPossible = inferStoreIfPossible } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } diff --git a/Sources/NSFetchedResultsController+Convenience.swift b/Sources/NSFetchedResultsController+Convenience.swift index 7c96fd4..e94c291 100644 --- a/Sources/NSFetchedResultsController+Convenience.swift +++ b/Sources/NSFetchedResultsController+Convenience.swift @@ -42,7 +42,7 @@ extension DataStack { - returns: an `NSFetchedResultsController` that observes the `DataStack` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.mainContext, @@ -62,7 +62,7 @@ extension DataStack { - returns: an `NSFetchedResultsController` that observes the `DataStack` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.mainContext, @@ -81,7 +81,7 @@ extension DataStack { - returns: an `NSFetchedResultsController` that observes the `DataStack` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.mainContext, @@ -100,7 +100,7 @@ extension DataStack { - returns: an `NSFetchedResultsController` that observes the `DataStack` */ @nonobjc - public func createFetchedResultsController(forDataStack dataStack: DataStack, _ from: From, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { + public func createFetchedResultsController(forDataStack dataStack: DataStack, _ from: From, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.mainContext, @@ -127,7 +127,7 @@ extension UnsafeDataTransaction { - returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.context, @@ -147,7 +147,7 @@ extension UnsafeDataTransaction { - returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.context, @@ -166,7 +166,7 @@ extension UnsafeDataTransaction { - returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ fetchClauses: FetchClause...) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.context, @@ -185,7 +185,7 @@ extension UnsafeDataTransaction { - returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction` */ @nonobjc - public func createFetchedResultsController(_ from: From, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { + public func createFetchedResultsController(_ from: From, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController { return Internals.createFRC( fromContext: self.context, @@ -205,7 +205,7 @@ extension Internals { // MARK: FilePrivate @available(macOS 10.12, *) - fileprivate static func createFRC(fromContext context: NSManagedObjectContext, from: From, sectionBy: SectionBy? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController { + fileprivate static func createFRC(fromContext context: NSManagedObjectContext, from: From, sectionBy: SectionBy? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController { let controller = Internals.CoreStoreFetchedResultsController( context: context, @@ -218,7 +218,7 @@ extension Internals { Internals.assert( fetchRequest.sortDescriptors?.isEmpty == false, - "An \(Internals.typeName(NSFetchedResultsController.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." + "An \(Internals.typeName(NSFetchedResultsController.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor." ) } ) diff --git a/Sources/NSManagedObjectContext+CoreStore.swift b/Sources/NSManagedObjectContext+CoreStore.swift index 0e0be6c..66114d2 100644 --- a/Sources/NSManagedObjectContext+CoreStore.swift +++ b/Sources/NSManagedObjectContext+CoreStore.swift @@ -87,9 +87,9 @@ extension NSManagedObjectContext { } @nonobjc - internal func objectPublisher(objectID: NSManagedObjectID) -> ObjectPublisher { + internal func objectPublisher(objectID: NSManagedObjectID) -> ObjectPublisher { - let cache: NSMapTable> = self.userInfo(for: .objectPublishersCache(D.self)) { + let cache: NSMapTable> = self.userInfo(for: .objectPublishersCache(O.self)) { return .strongToWeakObjects() } @@ -99,7 +99,7 @@ extension NSManagedObjectContext { return objectPublisher } - let objectPublisher = ObjectPublisher(objectID: objectID, context: self) + let objectPublisher = ObjectPublisher(objectID: objectID, context: self) cache.setObject(objectPublisher, forKey: objectID) return objectPublisher } diff --git a/Sources/NSManagedObjectContext+Querying.swift b/Sources/NSManagedObjectContext+Querying.swift index fa69c87..f54e9b6 100644 --- a/Sources/NSManagedObjectContext+Querying.swift +++ b/Sources/NSManagedObjectContext+Querying.swift @@ -34,7 +34,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { // MARK: FetchableSource @nonobjc - public func fetchExisting(_ object: D) -> D? { + public func fetchExisting(_ object: O) -> O? { let rawObject = object.cs_toRaw() if rawObject.objectID.isTemporaryID { @@ -75,12 +75,12 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchExisting(_ objectID: NSManagedObjectID) -> D? { + public func fetchExisting(_ objectID: NSManagedObjectID) -> O? { do { let existingObject = try self.existingObject(with: objectID) - return D.cs_fromRaw(object: existingObject) + return O.cs_fromRaw(object: existingObject) } catch _ { @@ -89,25 +89,25 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchExisting(_ objects: S) -> [D] where S.Iterator.Element == D { + public func fetchExisting(_ objects: S) -> [O] where S.Iterator.Element == O { return objects.compactMap({ self.fetchExisting($0.cs_id()) }) } @nonobjc - public func fetchExisting(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID { + public func fetchExisting(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID { return objectIDs.compactMap({ self.fetchExisting($0) }) } @nonobjc - public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> O? { return try self.fetchOne(from, fetchClauses) } @nonobjc - public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { + public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> O? { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -126,13 +126,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [O] { return try self.fetchAll(from, fetchClauses) } @nonobjc - public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { + public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [O] { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -152,13 +152,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { return try self.fetchCount(from, fetchClauses) } @nonobjc - public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { + public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -176,13 +176,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { return try self.fetchObjectID(from, fetchClauses) } @nonobjc - public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { + public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -201,13 +201,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { return try self.fetchObjectIDs(from, fetchClauses) } @nonobjc - public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { + public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -257,13 +257,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { // MARK: QueryableSource @nonobjc - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { return try self.queryValue(from, selectClause, queryClauses) } @nonobjc - public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { + public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -283,13 +283,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { } @nonobjc - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] { return try self.queryAttributes(from, selectClause, queryClauses) } @nonobjc - public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { + public func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -320,7 +320,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource { // MARK: Deleting @nonobjc - internal func deleteAll(_ from: From, _ deleteClauses: [FetchClause]) throws -> Int { + internal func deleteAll(_ from: From, _ deleteClauses: [FetchClause]) throws -> Int { let fetchRequest = Internals.CoreStoreFetchRequest() try from.applyToFetchRequest(fetchRequest, context: self) @@ -343,9 +343,9 @@ extension NSManagedObjectContext { // MARK: Fetching @nonobjc - internal func fetchOne(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> D? { + internal func fetchOne(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> O? { - var fetchResults: [D]? + var fetchResults: [O]? var fetchError: Error? self.performAndWait { @@ -371,9 +371,9 @@ extension NSManagedObjectContext { } @nonobjc - internal func fetchAll(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> [D] { + internal func fetchAll(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> [O] { - var fetchResults: [D]? + var fetchResults: [O]? var fetchError: Error? self.performAndWait { @@ -458,7 +458,7 @@ extension NSManagedObjectContext { // MARK: Querying @nonobjc - internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: Internals.CoreStoreFetchRequest) throws -> U? { + internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: Internals.CoreStoreFetchRequest) throws -> U? { var fetchResults: [Any]? var fetchError: Error? @@ -478,7 +478,7 @@ extension NSManagedObjectContext { if let rawResult = fetchResults.first as? NSDictionary, let rawObject = rawResult[selectTerms.first!.keyPathString] as? U.QueryableNativeType { - return Select.ReturnType.cs_fromQueryableNativeType(rawObject) + return Select.ReturnType.cs_fromQueryableNativeType(rawObject) } return nil } @@ -491,7 +491,7 @@ extension NSManagedObjectContext { } @nonobjc - internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: Internals.CoreStoreFetchRequest) throws -> Any? { + internal func queryValue(_ selectTerms: [SelectTerm], fetchRequest: Internals.CoreStoreFetchRequest) throws -> Any? { var fetchResults: [Any]? var fetchError: Error? @@ -555,7 +555,7 @@ extension NSManagedObjectContext { // MARK: Deleting @nonobjc - internal func deleteAll(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> Int { + internal func deleteAll(_ fetchRequest: Internals.CoreStoreFetchRequest) throws -> Int { var numberOfDeletedObjects: Int? var fetchError: Error? diff --git a/Sources/OrderBy.swift b/Sources/OrderBy.swift index 8c7564e..126f4ae 100644 --- a/Sources/OrderBy.swift +++ b/Sources/OrderBy.swift @@ -32,7 +32,7 @@ import CoreData /** The `OrderBy` clause specifies the sort order for results for a fetch or a query. */ -public struct OrderBy: OrderByClause, FetchClause, QueryClause, DeleteClause, Hashable { +public struct OrderBy: OrderByClause, FetchClause, QueryClause, DeleteClause, Hashable { /** Combines two `OrderBy` sort descriptors together @@ -102,7 +102,7 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause // MARK: OrderByClause - public typealias ObjectType = D + public typealias ObjectType = O public let sortDescriptors: [NSSortDescriptor] @@ -170,7 +170,7 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ keyPath: KeyPath) -> SortKey where D: NSManagedObject { + public static func ascending(_ keyPath: KeyPath) -> SortKey where O: NSManagedObject { return .ascending(keyPath._kvcKeyPathString!) } @@ -178,7 +178,7 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ keyPath: KeyPath) -> SortKey where D: NSManagedObject { + public static func descending(_ keyPath: KeyPath) -> SortKey where O: NSManagedObject { return .descending(keyPath._kvcKeyPathString!) } @@ -189,65 +189,65 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ attribute: KeyPath.Required>) -> SortKey { + public static func ascending(_ attribute: KeyPath.Required>) -> SortKey { - return .ascending(D.meta[keyPath: attribute].keyPath) + return .ascending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ attribute: KeyPath.Optional>) -> SortKey { + public static func ascending(_ attribute: KeyPath.Optional>) -> SortKey { - return .ascending(D.meta[keyPath: attribute].keyPath) + return .ascending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ attribute: KeyPath.Required>) -> SortKey { + public static func ascending(_ attribute: KeyPath.Required>) -> SortKey { - return .ascending(D.meta[keyPath: attribute].keyPath) + return .ascending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ attribute: KeyPath.Optional>) -> SortKey { + public static func ascending(_ attribute: KeyPath.Optional>) -> SortKey { - return .ascending(D.meta[keyPath: attribute].keyPath) + return .ascending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ attribute: KeyPath.Required>) -> SortKey { + public static func descending(_ attribute: KeyPath.Required>) -> SortKey { - return .descending(D.meta[keyPath: attribute].keyPath) + return .descending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ attribute: KeyPath.Optional>) -> SortKey { + public static func descending(_ attribute: KeyPath.Optional>) -> SortKey { - return .descending(D.meta[keyPath: attribute].keyPath) + return .descending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ attribute: KeyPath.Required>) -> SortKey { + public static func descending(_ attribute: KeyPath.Required>) -> SortKey { - return .descending(D.meta[keyPath: attribute].keyPath) + return .descending(O.meta[keyPath: attribute].keyPath) } /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ attribute: KeyPath.Optional>) -> SortKey { + public static func descending(_ attribute: KeyPath.Optional>) -> SortKey { - return .descending(D.meta[keyPath: attribute].keyPath) + return .descending(O.meta[keyPath: attribute].keyPath) } @@ -255,27 +255,33 @@ public struct OrderBy: OrderByClause, FetchClause, QueryClause fileprivate let descriptor: NSSortDescriptor } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } -// MARK: - OrderBy.SortKey where D: CoreStoreObject +// MARK: - OrderBy.SortKey where O: CoreStoreObject -extension OrderBy.SortKey where D: CoreStoreObject { +extension OrderBy.SortKey where O: CoreStoreObject { /** Indicates that the `KeyPathString` should be sorted in ascending order */ - public static func ascending(_ attribute: (D) -> K) -> OrderBy.SortKey { + public static func ascending(_ attribute: (O) -> K) -> OrderBy.SortKey { - return .ascending(attribute(D.meta).cs_keyPathString) + return .ascending(attribute(O.meta).cs_keyPathString) } /** Indicates that the `KeyPathString` should be sorted in descending order */ - public static func descending(_ attribute: (D) -> K) -> OrderBy.SortKey { + public static func descending(_ attribute: (O) -> K) -> OrderBy.SortKey { - return .descending(attribute(D.meta).cs_keyPathString) + return .descending(attribute(O.meta).cs_keyPathString) } } diff --git a/Sources/QueryChainBuilder.swift b/Sources/QueryChainBuilder.swift index 7c183bd..8b0d5c4 100644 --- a/Sources/QueryChainBuilder.swift +++ b/Sources/QueryChainBuilder.swift @@ -39,16 +39,22 @@ import CoreData ) ``` */ -public struct QueryChainBuilder: QueryChainableBuilderType { +public struct QueryChainBuilder: QueryChainableBuilderType { // MARK: QueryChainableBuilderType - public typealias ObjectType = D + public typealias ObjectType = O public typealias ResultType = R - public var from: From - public var select: Select + public var from: From + public var select: Select public var queryClauses: [QueryClause] = [] + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } diff --git a/Sources/QueryableSource.swift b/Sources/QueryableSource.swift index af58556..2e53ed1 100644 --- a/Sources/QueryableSource.swift +++ b/Sources/QueryableSource.swift @@ -45,7 +45,7 @@ public protocol QueryableSource: AnyObject { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? + func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? /** Queries aggregate values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. @@ -58,7 +58,7 @@ public protocol QueryableSource: AnyObject { - returns: the result of the the query, or `nil` if no match was found. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? + func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? /** Queries a property value or aggregate as specified by the `QueryChainableBuilderType` built from a chain of clauses. @@ -88,7 +88,7 @@ public protocol QueryableSource: AnyObject { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] + func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] /** Queries a dictionary of attribute values as specified by the `QueryClause`s. Requires at least a `Select` clause, and optional `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. @@ -101,7 +101,7 @@ public protocol QueryableSource: AnyObject { - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. - throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema. */ - func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] + func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] /** Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses. diff --git a/Sources/SectionBy.swift b/Sources/SectionBy.swift index 33388cf..3a0b662 100644 --- a/Sources/SectionBy.swift +++ b/Sources/SectionBy.swift @@ -40,7 +40,7 @@ import CoreData ``` */ @available(macOS 10.12, *) -public struct SectionBy { +public struct SectionBy { /** Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections @@ -70,17 +70,23 @@ public struct SectionBy { internal let sectionKeyPath: KeyPathString internal let sectionIndexTransformer: (_ sectionName: String?) -> String? + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } @available(macOS 10.12, *) -extension SectionBy where D: NSManagedObject { +extension SectionBy where O: NSManagedObject { /** Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections - parameter sectionKeyPath: the key path to use to group the objects into sections */ - public init(_ sectionKeyPath: KeyPath) { + public init(_ sectionKeyPath: KeyPath) { self.init(sectionKeyPath, { $0 }) } @@ -92,21 +98,21 @@ extension SectionBy where D: NSManagedObject { - parameter sectionKeyPath: the key path to use to group the objects into sections - parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name */ - public init(_ sectionKeyPath: KeyPath, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { + public init(_ sectionKeyPath: KeyPath, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { self.init(sectionKeyPath._kvcKeyPathString!, sectionIndexTransformer) } } @available(macOS 10.12, *) -extension SectionBy where D: CoreStoreObject { +extension SectionBy where O: CoreStoreObject { /** Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections - parameter sectionKeyPath: the key path to use to group the objects into sections */ - public init(_ sectionKeyPath: KeyPath.Required>) { + public init(_ sectionKeyPath: KeyPath.Required>) { self.init(sectionKeyPath, { $0 }) } @@ -116,7 +122,7 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections */ - public init(_ sectionKeyPath: KeyPath.Optional>) { + public init(_ sectionKeyPath: KeyPath.Optional>) { self.init(sectionKeyPath, { $0 }) } @@ -126,7 +132,7 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections */ - public init(_ sectionKeyPath: KeyPath.Required>) { + public init(_ sectionKeyPath: KeyPath.Required>) { self.init(sectionKeyPath, { $0 }) } @@ -136,7 +142,7 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections */ - public init(_ sectionKeyPath: KeyPath.Optional>) { + public init(_ sectionKeyPath: KeyPath.Optional>) { self.init(sectionKeyPath, { $0 }) } @@ -148,9 +154,9 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections - parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name */ - public init(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { + public init(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { - self.init(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + self.init(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -160,9 +166,9 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections - parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name */ - public init(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { + public init(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { - self.init(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + self.init(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -172,9 +178,9 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections - parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name */ - public init(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { + public init(_ sectionKeyPath: KeyPath.Required>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { - self.init(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + self.init(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } /** @@ -184,8 +190,8 @@ extension SectionBy where D: CoreStoreObject { - parameter sectionKeyPath: the key path to use to group the objects into sections - parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name */ - public init(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { + public init(_ sectionKeyPath: KeyPath.Optional>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) { - self.init(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) + self.init(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer) } } diff --git a/Sources/SectionMonitorBuilder.swift b/Sources/SectionMonitorBuilder.swift index 273e345..173e07d 100644 --- a/Sources/SectionMonitorBuilder.swift +++ b/Sources/SectionMonitorBuilder.swift @@ -41,13 +41,19 @@ import CoreData ``` */ @available(macOS 10.12, *) -public struct SectionMonitorChainBuilder: SectionMonitorBuilderType { +public struct SectionMonitorChainBuilder: SectionMonitorBuilderType { // MARK: SectionMonitorBuilderType - public var from: From - public var sectionBy: SectionBy + public var from: From + public var sectionBy: SectionBy public var fetchClauses: [FetchClause] = [] + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } diff --git a/Sources/Select.swift b/Sources/Select.swift index 8be74ca..dab14fb 100644 --- a/Sources/Select.swift +++ b/Sources/Select.swift @@ -52,7 +52,7 @@ public protocol SelectAttributesResultType: SelectResultType { /** The `SelectTerm` is passed to the `Select` clause to indicate the attributes/aggregate keys to be queried. */ -public enum SelectTerm: ExpressibleByStringLiteral, Hashable { +public enum SelectTerm: ExpressibleByStringLiteral, Hashable { /** Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. A shorter way to do the same is to assign from the string keypath directly: @@ -74,7 +74,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPathString) -> SelectTerm { + public static func attribute(_ keyPath: KeyPathString) -> SelectTerm { return ._attribute(keyPath) } @@ -91,7 +91,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { return ._aggregate( function: "average:", @@ -113,7 +113,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { return ._aggregate( function: "count:", @@ -135,7 +135,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { return ._aggregate( function: "max:", @@ -157,7 +157,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { return ._aggregate( function: "min:", @@ -179,7 +179,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm { return ._aggregate( function: "sum:", @@ -202,7 +202,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "objecID" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm { + public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm { return ._identity( alias: alias ?? "objectID", @@ -231,7 +231,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { // MARK: Equatable - public static func == (lhs: SelectTerm, rhs: SelectTerm) -> Bool { + public static func == (lhs: SelectTerm, rhs: SelectTerm) -> Bool { switch (lhs, rhs) { @@ -296,19 +296,25 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { case ._identity(let alias, _): return alias } } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } -// MARK: - SelectTerm where D: NSManagedObject +// MARK: - SelectTerm where O: NSManagedObject -extension SelectTerm where D: NSManagedObject { +extension SelectTerm where O: NSManagedObject { /** Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPath) -> SelectTerm { + public static func attribute(_ keyPath: KeyPath) -> SelectTerm { return self.attribute(keyPath._kvcKeyPathString!) } @@ -319,7 +325,7 @@ extension SelectTerm where D: NSManagedObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { return self.average(keyPath._kvcKeyPathString!, as: alias) } @@ -330,7 +336,7 @@ extension SelectTerm where D: NSManagedObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { return self.count(keyPath._kvcKeyPathString!, as: alias) } @@ -341,7 +347,7 @@ extension SelectTerm where D: NSManagedObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { return self.maximum(keyPath._kvcKeyPathString!, as: alias) } @@ -352,7 +358,7 @@ extension SelectTerm where D: NSManagedObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { return self.minimum(keyPath._kvcKeyPathString!, as: alias) } @@ -363,25 +369,25 @@ extension SelectTerm where D: NSManagedObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPath, as alias: KeyPathString? = nil) -> SelectTerm { return self.sum(keyPath._kvcKeyPathString!, as: alias) } } -// MARK: - SelectTerm where D: CoreStoreObject +// MARK: - SelectTerm where O: CoreStoreObject -extension SelectTerm where D: CoreStoreObject { +extension SelectTerm where O: CoreStoreObject { /** Provides a `SelectTerm` to a `Select` clause for querying an entity attribute. - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPath.Required>) -> SelectTerm { + public static func attribute(_ keyPath: KeyPath.Required>) -> SelectTerm { - return self.attribute(D.meta[keyPath: keyPath].keyPath) + return self.attribute(O.meta[keyPath: keyPath].keyPath) } /** @@ -389,9 +395,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPath.Optional>) -> SelectTerm { + public static func attribute(_ keyPath: KeyPath.Optional>) -> SelectTerm { - return self.attribute(D.meta[keyPath: keyPath].keyPath) + return self.attribute(O.meta[keyPath: keyPath].keyPath) } /** @@ -399,9 +405,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPath.Required>) -> SelectTerm { + public static func attribute(_ keyPath: KeyPath.Required>) -> SelectTerm { - return self.attribute(D.meta[keyPath: keyPath].keyPath) + return self.attribute(O.meta[keyPath: keyPath].keyPath) } /** @@ -409,9 +415,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter keyPath: the attribute name - returns: a `SelectTerm` to a `Select` clause for querying an entity attribute */ - public static func attribute(_ keyPath: KeyPath.Optional>) -> SelectTerm { + public static func attribute(_ keyPath: KeyPath.Optional>) -> SelectTerm { - return self.attribute(D.meta[keyPath: keyPath].keyPath) + return self.attribute(O.meta[keyPath: keyPath].keyPath) } /** @@ -420,9 +426,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.average(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.average(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -431,9 +437,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.average(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.average(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -442,9 +448,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.average(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.average(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -453,9 +459,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average()" is used - returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute */ - public static func average(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func average(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.average(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.average(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -464,10 +470,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.count(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.count(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -476,10 +482,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.count(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.count(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -488,10 +494,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.count(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.count(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -500,10 +506,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count()" is used - returns: a `SelectTerm` to a `Select` clause for a count query */ - public static func count(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func count(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.count(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.count(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -512,10 +518,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -524,10 +530,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -536,10 +542,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -548,10 +554,10 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max()" is used - returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute */ - public static func maximum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func maximum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.maximum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.maximum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -560,9 +566,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -571,9 +577,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -582,9 +588,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -593,9 +599,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min()" is used - returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute */ - public static func minimum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func minimum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.minimum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.minimum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -604,9 +610,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -615,9 +621,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -626,9 +632,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPath.Required>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias) } /** @@ -637,9 +643,9 @@ extension SelectTerm where D: CoreStoreObject { - parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum()" is used - returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute */ - public static func sum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { + public static func sum(_ keyPath: KeyPath.Optional>, as alias: KeyPathString? = nil) -> SelectTerm { - return self.sum(D.meta[keyPath: keyPath].keyPath, as: alias) + return self.sum(O.meta[keyPath: keyPath].keyPath, as: alias) } } @@ -672,7 +678,7 @@ extension SelectTerm where D: CoreStoreObject { - parameter sortDescriptors: a series of `NSSortDescriptor`s */ -public struct Select: SelectClause, Hashable { +public struct Select: SelectClause, Hashable { /** Initializes a `Select` clause with a list of `SelectTerm`s @@ -680,7 +686,7 @@ public struct Select: SelectClause, Hasha - parameter selectTerm: a `SelectTerm` - parameter selectTerms: a series of `SelectTerm`s */ - public init(_ selectTerm: SelectTerm, _ selectTerms: SelectTerm...) { + public init(_ selectTerm: SelectTerm, _ selectTerms: SelectTerm...) { self.selectTerms = [selectTerm] + selectTerms } @@ -690,7 +696,7 @@ public struct Select: SelectClause, Hasha - parameter selectTerms: a series of `SelectTerm`s */ - public init(_ selectTerms: [SelectTerm]) { + public init(_ selectTerms: [SelectTerm]) { self.selectTerms = selectTerms } @@ -698,7 +704,7 @@ public struct Select: SelectClause, Hasha // MARK: Equatable - public static func == (lhs: Select, rhs: Select) -> Bool { + public static func == (lhs: Select, rhs: Select) -> Bool { return lhs.selectTerms == rhs.selectTerms } @@ -706,10 +712,10 @@ public struct Select: SelectClause, Hasha // MARK: SelectClause - public typealias ObjectType = D + public typealias ObjectType = O public typealias ReturnType = T - public let selectTerms: [SelectTerm] + public let selectTerms: [SelectTerm] // MARK: Hashable @@ -806,6 +812,12 @@ public struct Select: SelectClause, Hasha fetchRequest.propertiesToFetch = propertiesToFetch } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } extension Select where T: NSManagedObjectID { @@ -819,25 +831,25 @@ extension Select where T: NSManagedObjectID { } } -extension Select where D: NSManagedObject { +extension Select where O: NSManagedObject { /** Initializes a `Select` that queries the value of an attribute pertained by a keyPath - parameter keyPath: the keyPath for the attribute */ - public init(_ keyPath: KeyPath) { + public init(_ keyPath: KeyPath) { self.init(.attribute(keyPath)) } } -extension Select where D: CoreStoreObject, T: ImportableAttributeType { +extension Select where O: CoreStoreObject, T: ImportableAttributeType { /** Initializes a `Select` that queries the value of an attribute pertained by a keyPath - parameter keyPath: the keyPath for the attribute */ - public init(_ keyPath: KeyPath.Required>) { + public init(_ keyPath: KeyPath.Required>) { self.init(.attribute(keyPath)) } @@ -846,19 +858,19 @@ extension Select where D: CoreStoreObject, T: ImportableAttributeType { Initializes a `Select` that queries the value of an attribute pertained by a keyPath - parameter keyPath: the keyPath for the attribute */ - public init(_ keyPath: KeyPath.Optional>) { + public init(_ keyPath: KeyPath.Optional>) { self.init(.attribute(keyPath)) } } -extension Select where D: CoreStoreObject, T: ImportableAttributeType & NSCoding & NSCopying { +extension Select where O: CoreStoreObject, T: ImportableAttributeType & NSCoding & NSCopying { /** Initializes a `Select` that queries the value of an attribute pertained by a keyPath - parameter keyPath: the keyPath for the attribute */ - public init(_ keyPath: KeyPath.Required>) { + public init(_ keyPath: KeyPath.Required>) { self.init(.attribute(keyPath)) } @@ -867,7 +879,7 @@ extension Select where D: CoreStoreObject, T: ImportableAttributeType & NSCoding Initializes a `Select` that queries the value of an attribute pertained by a keyPath - parameter keyPath: the keyPath for the attribute */ - public init(_ keyPath: KeyPath.Optional>) { + public init(_ keyPath: KeyPath.Optional>) { self.init(.attribute(keyPath)) } diff --git a/Sources/SynchronousDataTransaction.swift b/Sources/SynchronousDataTransaction.swift index 9044de8..1ad24f8 100644 --- a/Sources/SynchronousDataTransaction.swift +++ b/Sources/SynchronousDataTransaction.swift @@ -55,7 +55,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - parameter into: the `Into` clause indicating the destination `NSManagedObject` or `CoreStoreObject` entity type and the destination configuration - returns: a new `NSManagedObject` or `CoreStoreObject` instance of the specified entity type. */ - public override func create(_ into: Into) -> D { + public override func create(_ into: Into) -> O { Internals.assert( !self.isCommitted, @@ -71,7 +71,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - parameter object: the `NSManagedObject` or `CoreStoreObject` to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public override func edit(_ object: D?) -> D? { + public override func edit(_ object: O?) -> O? { Internals.assert( !self.isCommitted, @@ -88,7 +88,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction { - parameter objectID: the `NSManagedObjectID` for the object to be edited - returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`. */ - public override func edit(_ into: Into, _ objectID: NSManagedObjectID) -> D? { + public override func edit(_ into: Into, _ objectID: NSManagedObjectID) -> O? { Internals.assert( !self.isCommitted, diff --git a/Sources/UnsafeDataTransaction+Observing.swift b/Sources/UnsafeDataTransaction+Observing.swift index 72bd683..389df8e 100644 --- a/Sources/UnsafeDataTransaction+Observing.swift +++ b/Sources/UnsafeDataTransaction+Observing.swift @@ -50,7 +50,7 @@ extension UnsafeDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { + public func monitorList(_ from: From, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorList(from, fetchClauses) } @@ -62,10 +62,10 @@ extension UnsafeDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { + public func monitorList(_ from: From, _ fetchClauses: [FetchClause]) -> ListMonitor { Internals.assert( - fetchClauses.filter { $0 is OrderBy }.count > 0, + fetchClauses.filter { $0 is OrderBy }.count > 0, "A ListMonitor requires an OrderBy clause." ) @@ -109,7 +109,7 @@ extension UnsafeDataTransaction { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { + public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: FetchClause...) { self.monitorList(createAsynchronously: createAsynchronously, from, fetchClauses) } @@ -121,10 +121,10 @@ extension UnsafeDataTransaction { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { + public func monitorList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ fetchClauses: [FetchClause]) { Internals.assert( - fetchClauses.filter { $0 is OrderBy }.count > 0, + fetchClauses.filter { $0 is OrderBy }.count > 0, "A ListMonitor requires an OrderBy clause." ) @@ -173,7 +173,7 @@ extension UnsafeDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { + public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) -> ListMonitor { return self.monitorSectionedList(from, sectionBy, fetchClauses) } @@ -186,10 +186,10 @@ extension UnsafeDataTransaction { - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - returns: a `ListMonitor` instance that monitors changes to the list */ - public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { + public func monitorSectionedList(_ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) -> ListMonitor { Internals.assert( - fetchClauses.filter { $0 is OrderBy }.count > 0, + fetchClauses.filter { $0 is OrderBy }.count > 0, "A ListMonitor requires an OrderBy clause." ) @@ -234,7 +234,7 @@ extension UnsafeDataTransaction { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { + public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: FetchClause...) { self.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses) } @@ -247,10 +247,10 @@ extension UnsafeDataTransaction { - parameter sectionBy: a `SectionBy` clause indicating the keyPath for the attribute to use when sorting the list into sections. - parameter fetchClauses: a series of `FetchClause` instances for fetching the object list. Accepts `Where`, `OrderBy`, and `Tweak` clauses. */ - public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { + public func monitorSectionedList(createAsynchronously: @escaping (ListMonitor) -> Void, _ from: From, _ sectionBy: SectionBy, _ fetchClauses: [FetchClause]) { Internals.assert( - fetchClauses.filter { $0 is OrderBy }.count > 0, + fetchClauses.filter { $0 is OrderBy }.count > 0, "A ListMonitor requires an OrderBy clause." ) diff --git a/Sources/Where.Expression.swift b/Sources/Where.Expression.swift index c4b5685..8cb7cb8 100644 --- a/Sources/Where.Expression.swift +++ b/Sources/Where.Expression.swift @@ -80,7 +80,7 @@ extension Where { // MARK: KeyPathStringConvertible - public typealias ObjectType = D + public typealias ObjectType = O public typealias DestinationValueType = V @@ -103,6 +103,12 @@ extension Where { self.cs_keyPathString = component1 + "." + component2 } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } @@ -133,7 +139,7 @@ extension Where { let owner = dataStack.fetchOne(From().where((\.master ~ \.name) == "John")) ``` */ -public func ~(_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.SingleTarget, V> { +public func ~(_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.SingleTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -144,7 +150,7 @@ public func ~().where((\.master ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.SingleTarget, V> { +public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.SingleTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -155,7 +161,7 @@ public func ~ ().where((\.master ~ \.pets).count() > 1)) ``` */ -public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { +public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -166,7 +172,7 @@ public func ~ ().where((\.master ~ \.pets).count() > 1)) ``` */ -public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { +public func ~ (_ lhs: KeyPath, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -177,7 +183,7 @@ public func ~ ().where((\.spouse ~ \.father ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -188,7 +194,7 @@ public func ~ ().where((\.spouse ~ \.father ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -199,7 +205,7 @@ public func ~ ().where((\.spouse ~ \.father ~ \.children).count() > 0)) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -210,7 +216,7 @@ public func ~ ().where((\.spouse ~ \.father ~ \.children).count() > 0)) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -221,7 +227,7 @@ public func ~ ().where((\.spouse ~ \.pets ~ \.name).any() == "Spot")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, V> { return .init(lhs.cs_keyPathString, rhs.cs_keyPathString) } @@ -235,11 +241,11 @@ public func ~ ().where((\.master ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: KeyPath.ToOne>, _ rhs: KeyPath) -> Where.Expression.SingleTarget, K.DestinationValueType> where K.ObjectType == O { +public func ~ (_ lhs: KeyPath.ToOne>, _ rhs: KeyPath) -> Where.Expression.SingleTarget, K.DestinationValueType> where K.ObjectType == D { return .init( - D.meta[keyPath: lhs].cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + O.meta[keyPath: lhs].cs_keyPathString, + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -249,11 +255,11 @@ public func ~ ().where((\.master ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression where K.ObjectType == O { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression where K.ObjectType == D { return .init( lhs.cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -263,11 +269,11 @@ public func ~ ().where((\.master ~ \.name) == "John")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression where K.ObjectType == O { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression where K.ObjectType == D { return .init( lhs.cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -277,11 +283,11 @@ public func ~ ().where((\.master ~ \.pets).count() > 1)) ``` */ -public func ~ (_ lhs: KeyPath.ToOne>, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { +public func ~ (_ lhs: KeyPath.ToOne>, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == D { return .init( - D.meta[keyPath: lhs].cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + O.meta[keyPath: lhs].cs_keyPathString, + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -291,11 +297,11 @@ public func ~ ().where((\.master ~ \.pets).count() > 1)) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { return .init( lhs.cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -305,11 +311,11 @@ public func ~ ().where((\.master ~ \.pets).count() > 1)) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, K.DestinationValueType> where K.ObjectType == O { return .init( lhs.cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -319,11 +325,11 @@ public func ~ ().where((\.master ~ \.pets ~ \.name).any() == "Spot")) ``` */ -public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, KV.DestinationValueType> where KC.ObjectType == D, KV.ObjectType == O { +public func ~ (_ lhs: Where.Expression, _ rhs: KeyPath) -> Where.Expression.CollectionTarget, KV.DestinationValueType> where KC.ObjectType == O, KV.ObjectType == D { return .init( lhs.cs_keyPathString, - O.meta[keyPath: rhs].cs_keyPathString + D.meta[keyPath: rhs].cs_keyPathString ) } @@ -336,9 +342,9 @@ public func ~ ().where((\.master ~ \.name) == "John")) ``` */ -public func == (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func == (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(lhs.cs_keyPathString, isEqualTo: rhs) + return Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -347,9 +353,9 @@ public func == (_ lhs: Where.Expression().where((\.master ~ \.name) != "John")) ``` */ -public func != (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func != (_ lhs: Where.Expression, _ rhs: V) -> Where { - return !Where(lhs.cs_keyPathString, isEqualTo: rhs) + return !Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -358,9 +364,9 @@ public func != (_ lhs: Where.Expression().where(["John", "Joe"] ~= (\.master ~ \.name)) ``` */ -public func ~= (_ sequence: S, _ expression: Where.Expression) -> Where where S.Iterator.Element == V { +public func ~= (_ sequence: S, _ expression: Where.Expression) -> Where where S.Iterator.Element == V { - return Where(expression.cs_keyPathString, isMemberOf: sequence) + return Where(expression.cs_keyPathString, isMemberOf: sequence) } @@ -372,9 +378,9 @@ public func ~= (_ sequence: S, _ e let lonelyDog = dataStack.fetchOne(From().where((\.master ~ \.pets).count() < 2)) ``` */ -public func < (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func < (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: "<", operand: rhs) + return Where(expression: lhs, function: "<", operand: rhs) } /** @@ -383,9 +389,9 @@ public func < (_ lhs: Where.Exp let lonelyDog = dataStack.fetchOne(From().where((\.master ~ \.pets).count() <= 1) ``` */ -public func <= (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func <= (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: "<=", operand: rhs) + return Where(expression: lhs, function: "<=", operand: rhs) } /** @@ -394,9 +400,9 @@ public func <= (_ lhs: Where.Ex let happyDog = dataStack.fetchOne(From().where((\.master ~ \.pets).count() > 1) ``` */ -public func > (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func > (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: ">", operand: rhs) + return Where(expression: lhs, function: ">", operand: rhs) } /** @@ -405,9 +411,9 @@ public func > (_ lhs: Where.Exp let happyDog = dataStack.fetchOne(From().where((\.master ~ \.pets).count() >= 2) ``` */ -public func >= (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func >= (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: ">=", operand: rhs) + return Where(expression: lhs, function: ">=", operand: rhs) } @@ -419,9 +425,9 @@ public func >= (_ lhs: Where.Ex let dog = dataStack.fetchOne(From().where((\.master ~ \.name) == "John")) ``` */ -public func == (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func == (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(lhs.cs_keyPathString, isEqualTo: rhs) + return Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -430,9 +436,9 @@ public func == (_ lhs: Where.Expression().where((\.master ~ \.name) == "John")) ``` */ -public func == (_ lhs: Where.Expression, _ rhs: V?) -> Where { +public func == (_ lhs: Where.Expression, _ rhs: V?) -> Where { - return Where(lhs.cs_keyPathString, isEqualTo: rhs) + return Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -441,9 +447,9 @@ public func == (_ lhs: Where.Expression().where((\.master ~ \.name) != "John")) ``` */ -public func != (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func != (_ lhs: Where.Expression, _ rhs: V) -> Where { - return !Where(lhs.cs_keyPathString, isEqualTo: rhs) + return !Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -452,9 +458,9 @@ public func != (_ lhs: Where.Expression().where((\.master ~ \.name) != "John")) ``` */ -public func != (_ lhs: Where.Expression, _ rhs: V?) -> Where { +public func != (_ lhs: Where.Expression, _ rhs: V?) -> Where { - return !Where(lhs.cs_keyPathString, isEqualTo: rhs) + return !Where(lhs.cs_keyPathString, isEqualTo: rhs) } /** @@ -463,9 +469,9 @@ public func != (_ lhs: Where.Expression().where(["John", "Joe"] ~= (\.master ~ \.name)) ``` */ -public func ~= (_ sequence: S, _ expression: Where.Expression) -> Where where S.Iterator.Element == V { +public func ~= (_ sequence: S, _ expression: Where.Expression) -> Where where S.Iterator.Element == V { - return Where(expression.cs_keyPathString, isMemberOf: sequence) + return Where(expression.cs_keyPathString, isMemberOf: sequence) } @@ -477,9 +483,9 @@ public func ~= (_ sequence: S, _ e let childsPet = dataStack.fetchOne(From().where((\.master ~ \.age) < 10)) ``` */ -public func < (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func < (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: "<", operand: rhs) + return Where(expression: lhs, function: "<", operand: rhs) } /** @@ -488,9 +494,9 @@ public func < (_ lhs: Where.Exp let childsPet = dataStack.fetchOne(From().where((\.master ~ \.age) <= 10)) ``` */ -public func <= (_ lhs: Where.Expression, _ rhs: V?) -> Where { +public func <= (_ lhs: Where.Expression, _ rhs: V?) -> Where { - return Where(expression: lhs, function: "<=", operand: rhs) + return Where(expression: lhs, function: "<=", operand: rhs) } /** @@ -499,9 +505,9 @@ public func <= (_ lhs: Where.Ex let teensPet = dataStack.fetchOne(From().where((\.master ~ \.age) > 10)) ``` */ -public func > (_ lhs: Where.Expression, _ rhs: V) -> Where { +public func > (_ lhs: Where.Expression, _ rhs: V) -> Where { - return Where(expression: lhs, function: ">", operand: rhs) + return Where(expression: lhs, function: ">", operand: rhs) } /** @@ -510,9 +516,9 @@ public func > (_ lhs: Where.Exp let teensPet = dataStack.fetchOne(From().where((\.master ~ \.age) >= 10)) ``` */ -public func >= (_ lhs: Where.Expression, _ rhs: V?) -> Where { +public func >= (_ lhs: Where.Expression, _ rhs: V?) -> Where { - return Where(expression: lhs, function: ">=", operand: rhs) + return Where(expression: lhs, function: ">=", operand: rhs) } @@ -532,9 +538,9 @@ extension KeyPath where Root: NSManagedObject, Value: AllowedObjectiveCToManyRel } } -// MARK: - Where.Expression where D: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue +// MARK: - Where.Expression where O: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue -extension Where.Expression where D: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue { +extension Where.Expression where O: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue { /** Creates a `Where.Expression` clause for COUNT @@ -542,16 +548,16 @@ extension Where.Expression where D: NSManagedObject, T == Where.CollectionTar let dogsWithPlaymates = dataStack.fetchAll(From().where((\.master ~ \.pets).count() > 1)) ``` */ - public func count() -> Where.Expression { + public func count() -> Where.Expression { return .init(self.cs_keyPathString, "@count") } } -// MARK: - Where.Expression where D: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCKeyPathValue +// MARK: - Where.Expression where O: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCKeyPathValue -extension Where.Expression where D: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCKeyPathValue { +extension Where.Expression where O: NSManagedObject, T == Where.CollectionTarget, V: AllowedObjectiveCKeyPathValue { /** Creates a `Where.Expression` clause for ANY @@ -559,7 +565,7 @@ extension Where.Expression where D: NSManagedObject, T == Where.CollectionTar let dogsWithBadNamingSense = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.name).any() > "Spot")) ``` */ - public func any() -> Where.Expression { + public func any() -> Where.Expression { return .init("ANY " + self.cs_keyPathString) } @@ -570,7 +576,7 @@ extension Where.Expression where D: NSManagedObject, T == Where.CollectionTar let allPlaymatePuppies = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.age).all() > 5)) ``` */ - public func all() -> Where.Expression { + public func all() -> Where.Expression { return .init("ALL " + self.cs_keyPathString) } @@ -581,7 +587,7 @@ extension Where.Expression where D: NSManagedObject, T == Where.CollectionTar let dogs = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.name).any() > "Spot")) ``` */ - public func none() -> Where.Expression { + public func none() -> Where.Expression { return .init("NONE " + self.cs_keyPathString) } @@ -605,9 +611,9 @@ extension KeyPath where Root: CoreStoreObject, Value: ToManyRelationshipKeyPathS } -// MARK: - Where.Expression where D: CoreStoreObject, T == Where.CollectionTarget +// MARK: - Where.Expression where O: CoreStoreObject, T == Where.CollectionTarget -extension Where.Expression where D: CoreStoreObject, T == Where.CollectionTarget { +extension Where.Expression where O: CoreStoreObject, T == Where.CollectionTarget { /** Creates a `Where.Expression` clause for COUNT @@ -615,7 +621,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where.CollectionTar let dogsWithPlaymates = dataStack.fetchAll(From().where((\.master ~ \.pets).count() > 1)) ``` */ - public func count() -> Where.Expression { + public func count() -> Where.Expression { return .init(self.cs_keyPathString, "@count") } @@ -626,7 +632,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where.CollectionTar let dogsWithBadNamingSense = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.name).any() > "Spot")) ``` */ - public func any() -> Where.Expression { + public func any() -> Where.Expression { return .init("ANY " + self.cs_keyPathString) } @@ -637,7 +643,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where.CollectionTar let allPlaymatePuppies = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.age).all() > 5)) ``` */ - public func all() -> Where.Expression { + public func all() -> Where.Expression { return .init("ALL " + self.cs_keyPathString) } @@ -648,7 +654,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where.CollectionTar let dogs = dataStack.fetchAll(From().where((\.master ~ \.pets ~ \.name).any() > "Spot")) ``` */ - public func none() -> Where.Expression { + public func none() -> Where.Expression { return .init("NONE " + self.cs_keyPathString) } @@ -661,17 +667,17 @@ extension Where { // MARK: FilePrivate - fileprivate init(expression: Where.Expression, function: String, operand: V) { + fileprivate init(expression: Where.Expression, function: String, operand: V) { self.init("\(expression.cs_keyPathString) \(function) %@", operand.cs_toQueryableNativeType()) } - fileprivate init(expression: Where.Expression, function: String, operand: V) { + fileprivate init(expression: Where.Expression, function: String, operand: V) { self.init("\(expression.cs_keyPathString) \(function) %@", operand.cs_toQueryableNativeType()) } - fileprivate init(expression: Where.Expression, function: String, operand: V?) { + fileprivate init(expression: Where.Expression, function: String, operand: V?) { if let operand = operand { @@ -683,7 +689,7 @@ extension Where { } } - fileprivate init(expression: Where.Expression, function: String, operand: V?) { + fileprivate init(expression: Where.Expression, function: String, operand: V?) { if let operand = operand { diff --git a/Sources/Where.swift b/Sources/Where.swift index b882fce..9c01106 100644 --- a/Sources/Where.swift +++ b/Sources/Where.swift @@ -36,37 +36,37 @@ infix operator ||? : LogicalConjunctionPrecedence /** The `Where` clause specifies the conditions for a fetch or a query. */ -public struct Where: WhereClauseType, FetchClause, QueryClause, DeleteClause, Hashable { +public struct Where: WhereClauseType, FetchClause, QueryClause, DeleteClause, Hashable { /** Combines two `Where` predicates together using `AND` operator */ - public static func && (left: Where, right: Where) -> Where { + public static func && (left: Where, right: Where) -> Where { - return Where(NSCompoundPredicate(type: .and, subpredicates: [left.predicate, right.predicate])) + return Where(NSCompoundPredicate(type: .and, subpredicates: [left.predicate, right.predicate])) } /** Combines two `Where` predicates together using `OR` operator */ - public static func || (left: Where, right: Where) -> Where { + public static func || (left: Where, right: Where) -> Where { - return Where(NSCompoundPredicate(type: .or, subpredicates: [left.predicate, right.predicate])) + return Where(NSCompoundPredicate(type: .or, subpredicates: [left.predicate, right.predicate])) } /** Inverts the predicate of a `Where` clause using `NOT` operator */ - public static prefix func ! (clause: Where) -> Where { + public static prefix func ! (clause: Where) -> Where { - return Where(NSCompoundPredicate(type: .not, subpredicates: [clause.predicate])) + return Where(NSCompoundPredicate(type: .not, subpredicates: [clause.predicate])) } /** Combines two `Where` predicates together using `AND` operator. - returns: `left` if `right` is `nil`, otherwise equivalent to `(left && right)` */ - public static func &&? (left: Where, right: Where?) -> Where { + public static func &&? (left: Where, right: Where?) -> Where { if let right = right { @@ -79,7 +79,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause Combines two `Where` predicates together using `AND` operator. - returns: `right` if `left` is `nil`, otherwise equivalent to `(left && right)` */ - public static func &&? (left: Where?, right: Where) -> Where { + public static func &&? (left: Where?, right: Where) -> Where { if let left = left { @@ -92,7 +92,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause Combines two `Where` predicates together using `OR` operator. - returns: `left` if `right` is `nil`, otherwise equivalent to `(left || right)` */ - public static func ||? (left: Where, right: Where?) -> Where { + public static func ||? (left: Where, right: Where?) -> Where { if let right = right { @@ -105,7 +105,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause Combines two `Where` predicates together using `OR` operator. - returns: `right` if `left` is `nil`, otherwise equivalent to `(left || right)` */ - public static func ||? (left: Where?, right: Where) -> Where { + public static func ||? (left: Where?, right: Where) -> Where { if let left = left { @@ -127,7 +127,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause - parameter clause: the existing `Where` clause. */ - public init(_ clause: Where) { + public init(_ clause: Where) { self.init(clause.predicate) } @@ -200,7 +200,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause - parameter keyPath: the keyPath to compare with - parameter object: the arguments for the `==` operator */ - public init(_ keyPath: KeyPathString, isEqualTo object: D?) { + public init(_ keyPath: KeyPathString, isEqualTo object: O?) { switch object { @@ -269,7 +269,7 @@ public struct Where: WhereClauseType, FetchClause, QueryClause // MARK: WhereClauseType - public typealias ObjectType = D + public typealias ObjectType = O // MARK: FetchClause, QueryClause, DeleteClause @@ -302,12 +302,18 @@ public struct Where: WhereClauseType, FetchClause, QueryClause hasher.combine(self.predicate) } + + + // MARK: Deprecated + + @available(*, deprecated, renamed: "O") + public typealias D = O } -// MARK: - Where where D: NSManagedObject +// MARK: - Where where O: NSManagedObject -extension Where where D: NSManagedObject { +extension Where where O: NSManagedObject { /** Initializes a `Where` clause that compares equality to `nil` @@ -315,7 +321,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter null: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath, isEqualTo null: Void?) { + public init(_ keyPath: KeyPath, isEqualTo null: Void?) { self.init(keyPath._kvcKeyPathString!, isEqualTo: null) } @@ -326,7 +332,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter null: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath, isEqualTo null: Void?) { + public init(_ keyPath: KeyPath, isEqualTo null: Void?) { self.init(keyPath._kvcKeyPathString!, isEqualTo: null) } @@ -337,7 +343,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter value: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath, isEqualTo value: V?) { + public init(_ keyPath: KeyPath, isEqualTo value: V?) { self.init(keyPath._kvcKeyPathString!, isEqualTo: value) } @@ -348,7 +354,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter value: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath, isEqualTo value: O?) { + public init(_ keyPath: KeyPath, isEqualTo value: D?) { self.init(keyPath._kvcKeyPathString!, isEqualTo: value) } @@ -359,7 +365,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter objectID: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath, isEqualTo objectID: NSManagedObjectID) { + public init(_ keyPath: KeyPath, isEqualTo objectID: NSManagedObjectID) { self.init(keyPath._kvcKeyPathString!, isEqualTo: objectID) } @@ -370,7 +376,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element == V { + public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element == V { self.init(keyPath._kvcKeyPathString!, isMemberOf: list) } @@ -381,7 +387,7 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element == O { + public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element == D { self.init(keyPath._kvcKeyPathString!, isMemberOf: list) } @@ -392,16 +398,16 @@ extension Where where D: NSManagedObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID { + public init(_ keyPath: KeyPath, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID { self.init(keyPath._kvcKeyPathString!, isMemberOf: list) } } -// MARK: - Where where D: CoreStoreObject +// MARK: - Where where O: CoreStoreObject -extension Where where D: CoreStoreObject { +extension Where where O: CoreStoreObject { /** Initializes a `Where` clause that compares equality to `nil` @@ -409,9 +415,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter null: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.Optional>, isEqualTo null: Void?) { + public init(_ keyPath: KeyPath.Optional>, isEqualTo null: Void?) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: null) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: null) } /** @@ -420,9 +426,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter null: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.ToOne>, isEqualTo null: Void?) { + public init(_ keyPath: KeyPath.ToOne>, isEqualTo null: Void?) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: null) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: null) } /** @@ -431,9 +437,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter value: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.Required>, isEqualTo value: V?) { + public init(_ keyPath: KeyPath.Required>, isEqualTo value: V?) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: value) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: value) } /** @@ -442,9 +448,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter value: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.Optional>, isEqualTo value: V?) { + public init(_ keyPath: KeyPath.Optional>, isEqualTo value: V?) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: value) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: value) } /** @@ -453,9 +459,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter value: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.ToOne>, isEqualTo value: O?) { + public init(_ keyPath: KeyPath.ToOne>, isEqualTo value: D?) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: value) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: value) } /** @@ -464,9 +470,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter objectID: the arguments for the `==` operator */ - public init(_ keyPath: KeyPath.ToOne>, isEqualTo objectID: NSManagedObjectID) { + public init(_ keyPath: KeyPath.ToOne>, isEqualTo objectID: NSManagedObjectID) { - self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: objectID) + self.init(O.meta[keyPath: keyPath].keyPath, isEqualTo: objectID) } /** @@ -475,9 +481,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath.Required>, isMemberOf list: S) where S.Iterator.Element == V { + public init(_ keyPath: KeyPath.Required>, isMemberOf list: S) where S.Iterator.Element == V { - self.init(D.meta[keyPath: keyPath].keyPath, isMemberOf: list) + self.init(O.meta[keyPath: keyPath].keyPath, isMemberOf: list) } /** @@ -486,9 +492,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath.Optional>, isMemberOf list: S) where S.Iterator.Element == V { + public init(_ keyPath: KeyPath.Optional>, isMemberOf list: S) where S.Iterator.Element == V { - self.init(D.meta[keyPath: keyPath].keyPath, isMemberOf: list) + self.init(O.meta[keyPath: keyPath].keyPath, isMemberOf: list) } /** @@ -497,9 +503,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath.ToOne>, isMemberOf list: S) where S.Iterator.Element == O { + public init(_ keyPath: KeyPath.ToOne>, isMemberOf list: S) where S.Iterator.Element == D { - self.init(D.meta[keyPath: keyPath].keyPath, isMemberOf: list) + self.init(O.meta[keyPath: keyPath].keyPath, isMemberOf: list) } /** @@ -508,9 +514,9 @@ extension Where where D: CoreStoreObject { - parameter keyPath: the keyPath to compare with - parameter list: the sequence to check membership of */ - public init(_ keyPath: KeyPath.ToOne>, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID { + public init(_ keyPath: KeyPath.ToOne>, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID { - self.init(D.meta[keyPath: keyPath].keyPath, isMemberOf: list) + self.init(O.meta[keyPath: keyPath].keyPath, isMemberOf: list) } /** @@ -518,9 +524,9 @@ extension Where where D: CoreStoreObject { - parameter condition: closure that returns the `Where` clause */ - public init(_ condition: (D) -> Where) { + public init(_ condition: (O) -> Where) { - self = condition(D.meta) + self = condition(O.meta) } }