diff --git a/CoreStoreTests/DynamicModelTests.swift b/CoreStoreTests/DynamicModelTests.swift index 1cb66c9..cc0ce3a 100644 --- a/CoreStoreTests/DynamicModelTests.swift +++ b/CoreStoreTests/DynamicModelTests.swift @@ -266,6 +266,9 @@ class DynamicModelTests: BaseTestDataTestCase { let p3 = Where({ $0.age == 10 }) XCTAssertEqual(p3.predicate, NSPredicate(format: "%K == %d", "age", 10)) + + let totalAge = try transaction.queryValue(From().select(Int.self, .sum(\Dog.age))) + XCTAssertEqual(totalAge, 1) _ = try transaction.fetchAll( From() diff --git a/Sources/BaseDataTransaction+Querying.swift b/Sources/BaseDataTransaction+Querying.swift index 82c9e02..a3be030 100644 --- a/Sources/BaseDataTransaction+Querying.swift +++ b/Sources/BaseDataTransaction+Querying.swift @@ -136,7 +136,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { @@ -152,7 +153,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { @@ -173,7 +175,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` + - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ clauseChain: B) throws -> B.ObjectType? { @@ -189,7 +192,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { @@ -205,7 +209,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { @@ -226,7 +231,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` + - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ clauseChain: B) throws -> [B.ObjectType] { @@ -242,7 +248,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { @@ -258,7 +265,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { @@ -279,7 +287,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ clauseChain: B) throws -> Int { @@ -295,7 +304,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { @@ -311,7 +321,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { @@ -332,7 +343,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ clauseChain: B) throws -> NSManagedObjectID? { @@ -348,7 +360,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { @@ -364,7 +377,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { @@ -385,7 +399,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ clauseChain: B) throws -> [NSManagedObjectID] { @@ -407,7 +422,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { @@ -426,7 +442,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { @@ -449,7 +466,8 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType { @@ -469,6 +487,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -488,6 +507,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -520,6 +540,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource { ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryAttributes(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary { diff --git a/Sources/CoreStore+Querying.swift b/Sources/CoreStore+Querying.swift index 49fe4ae..1687b9f 100644 --- a/Sources/CoreStore+Querying.swift +++ b/Sources/CoreStore+Querying.swift @@ -80,7 +80,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { @@ -92,7 +93,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { @@ -109,7 +111,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` + - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchOne(_ clauseChain: B) throws -> B.ObjectType? { @@ -121,7 +124,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { @@ -133,7 +137,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { @@ -150,7 +155,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` + - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchAll(_ clauseChain: B) throws -> [B.ObjectType] { @@ -162,7 +168,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { @@ -174,7 +181,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { @@ -191,7 +199,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchCount(_ clauseChain: B) throws -> Int { @@ -203,7 +212,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { @@ -215,7 +225,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { @@ -232,7 +243,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectID(_ clauseChain: B) throws -> NSManagedObjectID? { @@ -244,7 +256,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { @@ -256,7 +269,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { @@ -273,7 +287,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func fetchObjectIDs(_ clauseChain: B) throws -> [NSManagedObjectID] { @@ -288,7 +303,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure 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? { @@ -303,7 +319,8 @@ public extension CoreStore { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure 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? { @@ -322,7 +339,8 @@ public extension CoreStore { ) ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func queryValue(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType { @@ -338,6 +356,7 @@ public extension CoreStore { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -353,6 +372,7 @@ public extension CoreStore { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -381,6 +401,7 @@ public extension CoreStore { ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public static func queryAttributes(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary { diff --git a/Sources/DataStack+Querying.swift b/Sources/DataStack+Querying.swift index 411ca10..31495c3 100644 --- a/Sources/DataStack+Querying.swift +++ b/Sources/DataStack+Querying.swift @@ -82,7 +82,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? { @@ -98,7 +99,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? { @@ -119,7 +121,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` + - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchOne(_ clauseChain: B) throws -> B.ObjectType? { @@ -135,7 +138,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] { @@ -151,7 +155,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] { @@ -172,7 +177,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` + - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchAll(_ clauseChain: B) throws -> [B.ObjectType] { @@ -188,7 +194,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int { @@ -204,7 +211,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int { @@ -225,7 +233,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchCount(_ clauseChain: B) throws -> Int { @@ -241,7 +250,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? { @@ -257,7 +267,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? { @@ -278,7 +289,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectID(_ clauseChain: B) throws -> NSManagedObjectID? { @@ -294,7 +306,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] { @@ -310,7 +323,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] { @@ -331,7 +345,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func fetchObjectIDs(_ clauseChain: B) throws -> [NSManagedObjectID] { @@ -353,7 +368,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? { @@ -372,7 +388,8 @@ extension DataStack: FetchableSource, QueryableSource { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? { @@ -395,7 +412,8 @@ extension DataStack: FetchableSource, QueryableSource { ) ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryValue(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType { @@ -415,6 +433,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -434,6 +453,7 @@ extension DataStack: FetchableSource, QueryableSource { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure 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]] { @@ -466,6 +486,7 @@ extension DataStack: FetchableSource, QueryableSource { ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ public func queryAttributes(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary { diff --git a/Sources/FetchableSource.swift b/Sources/FetchableSource.swift index eaa502c..1a24b66 100644 --- a/Sources/FetchableSource.swift +++ b/Sources/FetchableSource.swift @@ -71,7 +71,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchOne(_ from: From, _ fetchClauses: FetchClause...) throws -> D? @@ -80,7 +81,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s + - returns: the first `DynamicObject` instance that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchOne(_ from: From, _ fetchClauses: [FetchClause]) throws -> D? @@ -94,7 +96,8 @@ public protocol FetchableSource: class { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType` + - returns: the first `DynamicObject` instance that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchOne(_ clauseChain: B) throws -> B.ObjectType? @@ -103,7 +106,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchAll(_ from: From, _ fetchClauses: FetchClause...) throws -> [D] @@ -112,7 +116,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s + - returns: all `DynamicObject` instances that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchAll(_ from: From, _ fetchClauses: [FetchClause]) throws -> [D] @@ -126,7 +131,8 @@ public protocol FetchableSource: class { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType` + - returns: all `DynamicObject` instances that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchAll(_ clauseChain: B) throws -> [B.ObjectType] @@ -135,7 +141,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchCount(_ from: From, _ fetchClauses: FetchClause...) throws -> Int @@ -144,7 +151,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the number `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the number of `DynamicObject`s that satisfy the specified `FetchClause`s + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchCount(_ from: From, _ fetchClauses: [FetchClause]) throws -> Int @@ -158,7 +166,8 @@ public protocol FetchableSource: class { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the number `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the number of `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchCount(_ clauseChain: B) throws -> Int @@ -167,7 +176,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectID(_ from: From, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? @@ -176,7 +186,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchClause`s, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectID(_ from: From, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? @@ -190,7 +201,8 @@ public protocol FetchableSource: class { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for the first `DynamicObject` that satisfies the specified `FetchChainableBuilderType`, or `nil` if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectID(_ clauseChain: B) throws -> NSManagedObjectID? @@ -199,7 +211,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectIDs(_ from: From, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] @@ -208,7 +221,8 @@ public protocol FetchableSource: class { - parameter from: a `From` clause indicating the entity type - parameter fetchClauses: a series of `FetchClause` instances for the fetch request. Accepts `Where`, `OrderBy`, and `Tweak` clauses. - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchClause`s, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectIDs(_ from: From, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] @@ -222,7 +236,8 @@ public protocol FetchableSource: class { ) ``` - parameter clauseChain: a `FetchChainableBuilderType` built from a chain of clauses - - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` + - returns: the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType`, or an empty array if no match was found + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func fetchObjectIDs(_ clauseChain: B) throws -> [NSManagedObjectID] diff --git a/Sources/QueryableSource.swift b/Sources/QueryableSource.swift index 0ab5abf..42b2293 100644 --- a/Sources/QueryableSource.swift +++ b/Sources/QueryableSource.swift @@ -42,7 +42,8 @@ public protocol QueryableSource: class { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> U? @@ -54,7 +55,8 @@ public protocol QueryableSource: class { - parameter from: a `From` clause indicating the entity type - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - 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: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryValue(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> U? @@ -70,7 +72,8 @@ public protocol QueryableSource: class { ) ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the property/aggregate to fetch and the series of queries for the request. - - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - returns: the result of the the query as specified by the `QueryChainableBuilderType`, or `nil` if no match was found. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryValue(_ clauseChain: B) throws -> B.ResultType? where B.ResultType: QueryableAttributeType @@ -83,6 +86,7 @@ public protocol QueryableSource: class { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: QueryClause...) throws -> [[String: Any]] @@ -95,6 +99,7 @@ public protocol QueryableSource: class { - parameter selectClause: a `Select` clause indicating the properties to fetch, and with the generic type indicating the return type. - parameter queryClauses: a series of `QueryClause` instances for the query request. Accepts `Where`, `OrderBy`, `GroupBy`, and `Tweak` clauses. - returns: the result of the the query. The type of the return value is specified by the generic type of the `Select` parameter. + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryAttributes(_ from: From, _ selectClause: Select, _ queryClauses: [QueryClause]) throws -> [[String: Any]] @@ -120,6 +125,7 @@ public protocol QueryableSource: class { ``` - parameter clauseChain: a `QueryChainableBuilderType` indicating the properties to fetch and the series of queries for the request. - returns: the result of the the query as specified by the `QueryChainableBuilderType` + - throws: a `CoreStoreError` value indicating the failure if the specified entity could not be found in any store's schema. */ func queryAttributes(_ clauseChain: B) throws -> [[String: Any]] where B.ResultType == NSDictionary diff --git a/Sources/Select.swift b/Sources/Select.swift index b3cb8b1..50c1a02 100644 --- a/Sources/Select.swift +++ b/Sources/Select.swift @@ -298,6 +298,9 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable { } } + +// MARK: - SelectTerm where D: NSManagedObject + extension SelectTerm where D: NSManagedObject { /** @@ -366,6 +369,9 @@ extension SelectTerm where D: NSManagedObject { } } + +// MARK: - SelectTerm where D: CoreStoreObject + extension SelectTerm where D: CoreStoreObject { /**