Unify generic labeling

This commit is contained in:
John Estropia
2019-10-22 16:16:47 +09:00
parent 3d8bdf1cf3
commit 80166a42bb
37 changed files with 711 additions and 639 deletions

View File

@@ -31,12 +31,12 @@ import CoreStore
// MARK: - XCTAssertAllEqual
private func XCTAssertAllEqual<D>(_ whereClauses: Where<D>...) {
private func XCTAssertAllEqual<O>(_ whereClauses: Where<O>...) {
XCTAssertAllEqual(whereClauses)
}
private func XCTAssertAllEqual<D>(_ whereClauses: [Where<D>]) {
private func XCTAssertAllEqual<O>(_ whereClauses: [Where<O>]) {
for i in whereClauses.indices {

View File

@@ -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<D>(_ into: Into<D>) -> D {
public override func create<O>(_ into: Into<O>) -> 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<D: DynamicObject>(_ object: D?) -> D? {
public override func edit<O: DynamicObject>(_ 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<D>(_ into: Into<D>, _ objectID: NSManagedObjectID) -> D? {
public override func edit<O>(_ into: Into<O>, _ objectID: NSManagedObjectID) -> O? {
Internals.assert(
!self.isCommitted,

View File

@@ -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<D: ImportableObject>(
_ into: Into<D>,
source: D.ImportSource) throws -> D? {
public func importObject<O: ImportableObject>(
_ into: Into<O>,
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<D: ImportableObject>(
_ object: D,
source: D.ImportSource) throws {
public func importObject<O: ImportableObject>(
_ 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<D: ImportableObject, S: Sequence>(
_ into: Into<D>,
sourceArray: S) throws -> [D] where S.Iterator.Element == D.ImportSource {
public func importObjects<O: ImportableObject, S: Sequence>(
_ into: Into<O>,
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<D: ImportableUniqueObject>(
_ into: Into<D>,
source: D.ImportSource) throws -> D? {
public func importUniqueObject<O: ImportableUniqueObject>(
_ into: Into<O>,
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<D>(uniqueIDKeyPath, isEqualTo: uniqueIDValue)) {
if let object = try self.fetchOne(From(entityType), Where<O>(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<D: ImportableUniqueObject, S: Sequence>(
_ into: Into<D>,
public func importUniqueObjects<O: ImportableUniqueObject, S: Sequence>(
_ into: Into<O>,
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<D.UniqueIDType, D.ImportSource>()
var importSourceByID = Dictionary<O.UniqueIDType, O.ImportSource>()
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<D.UniqueIDType, D>()
var existingObjectsByID = Dictionary<O.UniqueIDType, O>()
try self
.fetchAll(From(entityType), Where<D>(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs))
.fetchAll(From(entityType), Where<O>(entityType.uniqueIDKeyPath, isMemberOf: sortedIDs))
.forEach { existingObjectsByID[$0.uniqueIDValue] = $0 }
var processedObjectIDs = Set<D.UniqueIDType>()
var result = [D]()
var processedObjectIDs = Set<O.UniqueIDType>()
var result = [O]()
for objectID in sortedIDs where !processedObjectIDs.contains(objectID) {

View File

@@ -39,7 +39,7 @@ extension BaseDataTransaction: FetchableSource, QueryableSource {
- returns: the number of `DynamicObject`s deleted
*/
@discardableResult
public func deleteAll<D>(_ from: From<D>, _ deleteClauses: DeleteClause...) throws -> Int {
public func deleteAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ deleteClauses: [DeleteClause]) throws -> Int {
public func deleteAll<O>(_ from: From<O>, _ 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<D: DynamicObject>(_ object: D) -> D? {
public func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D? {
public func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
Internals.assert(
self.isRunningInAllowedQueue(),

View File

@@ -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<D>(_ into: Into<D>) -> D {
public func create<O>(_ into: Into<O>) -> 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<D: DynamicObject>(_ object: D?) -> D? {
public func edit<O: DynamicObject>(_ 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<D>(_ into: Into<D>, _ objectID: NSManagedObjectID) -> D? {
public func edit<O>(_ into: Into<O>, _ 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<D: DynamicObject>(_ object: D) -> Bool {
public func objectHasPersistentChangedValues<O: DynamicObject>(_ 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<D: DynamicObject>(_ entity: D.Type) -> Set<D> {
public func insertedObjects<O: DynamicObject>(_ entity: O.Type) -> Set<O> {
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<D: DynamicObject>(_ entity: D.Type) -> Set<NSManagedObjectID> {
public func insertedObjectIDs<O: DynamicObject>(_ entity: O.Type) -> Set<NSManagedObjectID> {
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<D: DynamicObject>(_ entity: D.Type) -> Set<D> {
public func updatedObjects<O: DynamicObject>(_ entity: O.Type) -> Set<O> {
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<D: DynamicObject>(_ entity: D.Type) -> Set<NSManagedObjectID> {
public func updatedObjectIDs<O: DynamicObject>(_ entity: O.Type) -> Set<NSManagedObjectID> {
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<D: DynamicObject>(_ entity: D.Type) -> Set<D> {
public func deletedObjects<O: DynamicObject>(_ entity: O.Type) -> Set<O> {
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<D: DynamicObject>(_ entity: D.Type) -> Set<NSManagedObjectID> {
public func deletedObjectIDs<O: DynamicObject>(_ entity: O.Type) -> Set<NSManagedObjectID> {
Internals.assert(
self.isRunningInAllowedQueue(),

View File

@@ -145,7 +145,7 @@ public final class CSFrom: NSObject {
public let bridgeToSwift: From<NSManagedObject>
public init<D: NSManagedObject>(_ swiftValue: From<D>) {
public init<O: NSManagedObject>(_ swiftValue: From<O>) {
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

View File

@@ -104,7 +104,7 @@ public final class CSGroupBy: NSObject, CSQueryClause {
public let bridgeToSwift: GroupBy<NSManagedObject>
public init<D: NSManagedObject>(_ swiftValue: GroupBy<D>) {
public init<O: NSManagedObject>(_ swiftValue: GroupBy<O>) {
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

View File

@@ -112,7 +112,7 @@ public final class CSInto: NSObject {
public let bridgeToSwift: Into<NSManagedObject>
public required init<D: NSManagedObject>(_ swiftValue: Into<D>) {
public required init<O: NSManagedObject>(_ swiftValue: Into<O>) {
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

View File

@@ -112,7 +112,7 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
public let bridgeToSwift: OrderBy<NSManagedObject>
public init<D: NSManagedObject>(_ swiftValue: OrderBy<D>) {
public init<O: NSManagedObject>(_ swiftValue: OrderBy<O>) {
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

View File

@@ -76,7 +76,7 @@ public final class CSSectionBy: NSObject {
public let bridgeToSwift: SectionBy<NSManagedObject>
public init<D>(_ swiftValue: SectionBy<D>) {
public init<O>(_ swiftValue: SectionBy<O>) {
self.bridgeToSwift = swiftValue.downcast()
super.init()

View File

@@ -177,7 +177,7 @@ public final class CSSelectTerm: NSObject {
public let bridgeToSwift: SelectTerm<NSManagedObject>
public init<D: NSManagedObject>(_ swiftValue: SelectTerm<D>) {
public init<O: NSManagedObject>(_ swiftValue: SelectTerm<O>) {
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<D: NSManagedObject, T: QueryableAttributeType>(_ swiftValue: Select<D, T>) {
public init<O: NSManagedObject, T: QueryableAttributeType>(_ swiftValue: Select<O, T>) {
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<D: NSManagedObject, T>(_ swiftValue: Select<D, T>) {
public init<O: NSManagedObject, T>(_ swiftValue: Select<O, T>) {
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

View File

@@ -151,7 +151,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
public let bridgeToSwift: Where<NSManagedObject>
public init<D: NSManagedObject>(_ swiftValue: Where<D>) {
public init<O: NSManagedObject>(_ swiftValue: Where<O>) {
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

View File

@@ -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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public static func monitorList<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public static func monitorList<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: FetchClause...) {
public static func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: [FetchClause]) {
public static func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ 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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public static func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public static func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) {
public static func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) {
public static func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) {
CoreStoreDefaults.dataStack.monitorSectionedList(createAsynchronously: createAsynchronously, from, sectionBy, fetchClauses)
}

View File

@@ -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<D: DynamicObject>(_ object: D) -> D? {
public static func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D? {
public static func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D {
public static func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
public static func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
public static func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
public static func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
public static func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
public static func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
public static func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
public static func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
public static func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
public static func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
public static func fetchObjectIDs<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
public static func fetchObjectIDs<O>(_ from: From<O>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
public static func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public static func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
public static func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
public static func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public static func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
public static func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
return try CoreStoreDefaults.dataStack.queryAttributes(from, selectClause, queryClauses)
}

View File

@@ -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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListPublisher<D> {
public func listPublisher<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> ListPublisher<O> {
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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListPublisher<D> {
public func listPublisher<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> ListPublisher<O> {
return ListPublisher(
dataStack: self,
@@ -75,7 +75,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListPublisher<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListPublisher<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListPublisher<D> {
public func listPublisher<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> ListPublisher<O> {
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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListPublisher<D> {
public func listPublisher<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> ListPublisher<O> {
return ListPublisher(
dataStack: self,
@@ -144,7 +144,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListPublisher<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListPublisher<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
)
}
)

View File

@@ -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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public func monitorList<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public func monitorList<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
Internals.assert(
Thread.isMainThread,
@@ -82,7 +82,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListMonitor<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListMonitor<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: FetchClause...) {
public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: [FetchClause]) {
public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ fetchClauses: [FetchClause]) {
Internals.assert(
Thread.isMainThread,
@@ -147,7 +147,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListMonitor<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListMonitor<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
Internals.assert(
Thread.isMainThread,
@@ -221,7 +221,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListMonitor<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListMonitor<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) {
Internals.assert(
Thread.isMainThread,
@@ -292,7 +292,7 @@ extension DataStack {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(ListMonitor<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(ListMonitor<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
)
},
createAsynchronously: createAsynchronously

View File

@@ -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<D: DynamicObject>(_ object: D) -> D? {
public func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D? {
public func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
Internals.assert(
Thread.isMainThread,

View File

@@ -39,14 +39,20 @@ import CoreData
)
```
*/
public struct FetchChainBuilder<D: DynamicObject>: FetchChainableBuilderType {
public struct FetchChainBuilder<O: DynamicObject>: FetchChainableBuilderType {
// MARK: FetchChainableBuilderType
public typealias ObjectType = D
public typealias ObjectType = O
public var from: From<D>
public var from: From<O>
public var fetchClauses: [FetchClause] = []
// MARK: Deprecated
@available(*, deprecated, renamed: "O")
public typealias D = O
}

View File

@@ -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<D: DynamicObject>(_ object: D) -> D?
func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D?
func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D
func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID
func fetchExisting<O: DynamicObject, S: Sequence>(_ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D?
func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D?
func fetchOne<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D]
func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D]
func fetchAll<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int
func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int
func fetchCount<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID?
func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID?
func fetchObjectID<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID]
func fetchObjectIDs<O>(_ from: From<O>, _ 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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID]
func fetchObjectIDs<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID]
/**
Fetches the `NSManagedObjectID` for all `DynamicObject`s that satisfy the specified `FetchChainableBuilderType` built from a chain of clauses.

View File

@@ -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<D>) -> FetchChainBuilder<D> {
public func `where`(_ clause: Where<O>) -> FetchChainBuilder<O> {
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<D> {
public func `where`(format: String, _ args: Any...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: Where<D>(format, argumentArray: args))
return self.fetchChain(appending: Where<O>(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<D> {
public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder<O> {
return self.fetchChain(appending: Where<D>(format, argumentArray: argumentArray))
return self.fetchChain(appending: Where<O>(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<D>) -> FetchChainBuilder<D> {
public func orderBy(_ clause: OrderBy<O>) -> FetchChainBuilder<O> {
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<D>.SortKey, _ sortKeys: OrderBy<D>.SortKey...) -> FetchChainBuilder<D> {
public func orderBy(_ sortKey: OrderBy<O>.SortKey, _ sortKeys: OrderBy<O>.SortKey...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: OrderBy<D>([sortKey] + sortKeys))
return self.fetchChain(appending: OrderBy<O>([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<D>.SortKey]) -> FetchChainBuilder<D> {
public func orderBy(_ sortKeys: [OrderBy<O>.SortKey]) -> FetchChainBuilder<O> {
return self.fetchChain(appending: OrderBy<D>(sortKeys))
return self.fetchChain(appending: OrderBy<O>(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<NSFetchRequestResult>) -> Void) -> FetchChainBuilder<D> {
public func tweak(_ fetchRequest: @escaping (NSFetchRequest<NSFetchRequestResult>) -> Void) -> FetchChainBuilder<O> {
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<D> {
public func appending(_ clause: FetchClause) -> FetchChainBuilder<O> {
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<S: Sequence>(contentsOf clauses: S) -> FetchChainBuilder<D> where S.Element == FetchClause {
public func appending<S: Sequence>(contentsOf clauses: S) -> FetchChainBuilder<O> 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<R>(_ clause: Select<D, R>) -> QueryChainBuilder<D, R> {
public func select<R>(_ clause: Select<O, R>) -> QueryChainBuilder<O, R> {
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<R>(_ resultType: R.Type, _ selectTerm: SelectTerm<D>, _ selectTerms: SelectTerm<D>...) -> QueryChainBuilder<D, R> {
public func select<R>(_ resultType: R.Type, _ selectTerm: SelectTerm<O>, _ selectTerms: SelectTerm<O>...) -> QueryChainBuilder<O, R> {
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<R>(_ resultType: R.Type, _ selectTerms: [SelectTerm<D>]) -> QueryChainBuilder<D, R> {
public func select<R>(_ resultType: R.Type, _ selectTerms: [SelectTerm<O>]) -> QueryChainBuilder<O, R> {
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<D>) -> SectionMonitorChainBuilder<D> {
public func sectionBy(_ clause: SectionBy<O>) -> SectionMonitorChainBuilder<O> {
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<D> {
public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder<O> {
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<D> {
public func sectionBy(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
return .init(
from: self,
@@ -226,21 +226,21 @@ extension From {
// MARK: Private
private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder<D> {
private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder<O> {
return .init(from: self, fetchClauses: [clause])
}
private func fetchChain<S: Sequence>(appending clauses: S) -> FetchChainBuilder<D> where S.Element == FetchClause {
private func fetchChain<S: Sequence>(appending clauses: S) -> FetchChainBuilder<O> 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<R>(_ keyPath: KeyPath<D, R>) -> QueryChainBuilder<D, R> {
public func select<R>(_ keyPath: KeyPath<O, R>) -> QueryChainBuilder<O, R> {
return self.select(R.self, [SelectTerm<D>.attribute(keyPath)])
return self.select(R.self, [SelectTerm<O>.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<T>(_ sectionKeyPath: KeyPath<D, T>) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, T>) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, T>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, T>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
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`<T: AnyWhereClause>(_ clause: (D) -> T) -> FetchChainBuilder<D> {
public func `where`<T: AnyWhereClause>(_ clause: (O) -> T) -> FetchChainBuilder<O> {
return self.fetchChain(appending: clause(D.meta))
return self.fetchChain(appending: clause(O.meta))
}
public func `where`(combinedByAnd clause: Where<D>, _ others: Where<D>...) -> FetchChainBuilder<D> {
public func `where`(combinedByAnd clause: Where<O>, _ others: Where<O>...) -> FetchChainBuilder<O> {
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<R>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<R>>) -> QueryChainBuilder<D, R> {
public func select<R>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<R>>) -> QueryChainBuilder<O, R> {
return self.select(R.self, [SelectTerm<D>.attribute(keyPath)])
return self.select(R.self, [SelectTerm<O>.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<R>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<R>>) -> QueryChainBuilder<D, R> {
public func select<R>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<R>>) -> QueryChainBuilder<O, R> {
return self.select(R.self, [SelectTerm<D>.attribute(keyPath)])
return self.select(R.self, [SelectTerm<O>.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<R>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<R>>) -> QueryChainBuilder<D, R> {
public func select<R>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<R>>) -> QueryChainBuilder<O, R> {
return self.select(R.self, [SelectTerm<D>.attribute(keyPath)])
return self.select(R.self, [SelectTerm<O>.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<R>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<R>>) -> QueryChainBuilder<D, R> {
public func select<R>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<R>>) -> QueryChainBuilder<O, R> {
return self.select(R.self, [SelectTerm<D>.attribute(keyPath)])
return self.select(R.self, [SelectTerm<O>.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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<D> {
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> SectionMonitorChainBuilder<O> {
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<D>) -> FetchChainBuilder<D> {
public func `where`(_ clause: Where<O>) -> FetchChainBuilder<O> {
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<D> {
public func `where`(format: String, _ args: Any...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: Where<D>(format, argumentArray: args))
return self.fetchChain(appending: Where<O>(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<D> {
public func `where`(format: String, argumentArray: [Any]?) -> FetchChainBuilder<O> {
return self.fetchChain(appending: Where<D>(format, argumentArray: argumentArray))
return self.fetchChain(appending: Where<O>(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<D>) -> FetchChainBuilder<D> {
public func orderBy(_ clause: OrderBy<O>) -> FetchChainBuilder<O> {
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<D>.SortKey, _ sortKeys: OrderBy<D>.SortKey...) -> FetchChainBuilder<D> {
public func orderBy(_ sortKey: OrderBy<O>.SortKey, _ sortKeys: OrderBy<O>.SortKey...) -> FetchChainBuilder<O> {
return self.fetchChain(appending: OrderBy<D>([sortKey] + sortKeys))
return self.fetchChain(appending: OrderBy<O>([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<D>.SortKey]) -> FetchChainBuilder<D> {
public func orderBy(_ sortKeys: [OrderBy<O>.SortKey]) -> FetchChainBuilder<O> {
return self.fetchChain(appending: OrderBy<D>(sortKeys))
return self.fetchChain(appending: OrderBy<O>(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<NSFetchRequestResult>) -> Void) -> FetchChainBuilder<D> {
public func tweak(_ fetchRequest: @escaping (NSFetchRequest<NSFetchRequestResult>) -> Void) -> FetchChainBuilder<O> {
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<D> {
public func appending(_ clause: FetchClause) -> FetchChainBuilder<O> {
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<S: Sequence>(contentsOf clauses: S) -> FetchChainBuilder<D> where S.Element == FetchClause {
public func appending<S: Sequence>(contentsOf clauses: S) -> FetchChainBuilder<O> where S.Element == FetchClause {
return self.fetchChain(appending: clauses)
}
@@ -560,7 +560,7 @@ extension FetchChainBuilder {
// MARK: Private
private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder<D> {
private func fetchChain(appending clause: FetchClause) -> FetchChainBuilder<O> {
return .init(
from: self.from,
@@ -568,7 +568,7 @@ extension FetchChainBuilder {
)
}
private func fetchChain<S: Sequence>(appending clauses: S) -> FetchChainBuilder<D> where S.Element == FetchClause {
private func fetchChain<S: Sequence>(appending clauses: S) -> FetchChainBuilder<O> 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`<T: AnyWhereClause>(_ clause: (D) -> T) -> FetchChainBuilder<D> {
public func `where`<T: AnyWhereClause>(_ clause: (O) -> T) -> FetchChainBuilder<O> {
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<D>) -> QueryChainBuilder<D, R> {
public func `where`(_ clause: Where<O>) -> QueryChainBuilder<O, R> {
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<D, R> {
public func `where`(format: String, _ args: Any...) -> QueryChainBuilder<O, R> {
return self.queryChain(appending: Where<D>(format, argumentArray: args))
return self.queryChain(appending: Where<O>(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<D, R> {
public func `where`(format: String, argumentArray: [Any]?) -> QueryChainBuilder<O, R> {
return self.queryChain(appending: Where<D>(format, argumentArray: argumentArray))
return self.queryChain(appending: Where<O>(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<D>) -> QueryChainBuilder<D, R> {
public func orderBy(_ clause: OrderBy<O>) -> QueryChainBuilder<O, R> {
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<D>.SortKey, _ sortKeys: OrderBy<D>.SortKey...) -> QueryChainBuilder<D, R> {
public func orderBy(_ sortKey: OrderBy<O>.SortKey, _ sortKeys: OrderBy<O>.SortKey...) -> QueryChainBuilder<O, R> {
return self.queryChain(appending: OrderBy<D>([sortKey] + sortKeys))
return self.queryChain(appending: OrderBy<O>([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<D>.SortKey]) -> QueryChainBuilder<D, R> {
public func orderBy(_ sortKeys: [OrderBy<O>.SortKey]) -> QueryChainBuilder<O, R> {
return self.queryChain(appending: OrderBy<D>(sortKeys))
return self.queryChain(appending: OrderBy<O>(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<NSFetchRequestResult>) -> Void) -> QueryChainBuilder<D, R> {
public func tweak(_ fetchRequest: @escaping (NSFetchRequest<NSFetchRequestResult>) -> Void) -> QueryChainBuilder<O, R> {
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<D>) -> QueryChainBuilder<D, R> {
public func groupBy(_ clause: GroupBy<O>) -> QueryChainBuilder<O, R> {
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<D, R> {
public func groupBy(_ keyPath: KeyPathString, _ keyPaths: KeyPathString...) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>([keyPath] + keyPaths))
return self.groupBy(GroupBy<O>([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<D, R> {
public func groupBy(_ keyPaths: [KeyPathString]) -> QueryChainBuilder<O, R> {
return self.queryChain(appending: GroupBy<D>(keyPaths))
return self.queryChain(appending: GroupBy<O>(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<D, R> {
public func appending(_ clause: QueryClause) -> QueryChainBuilder<O, R> {
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<S: Sequence>(contentsOf clauses: S) -> QueryChainBuilder<D, R> where S.Element == QueryClause {
public func appending<S: Sequence>(contentsOf clauses: S) -> QueryChainBuilder<O, R> where S.Element == QueryClause {
return self.queryChain(appending: clauses)
}
@@ -732,7 +732,7 @@ extension QueryChainBuilder {
// MARK: Private
private func queryChain(appending clause: QueryClause) -> QueryChainBuilder<D, R> {
private func queryChain(appending clause: QueryClause) -> QueryChainBuilder<O, R> {
return .init(
from: self.from,
@@ -741,7 +741,7 @@ extension QueryChainBuilder {
)
}
private func queryChain<S: Sequence>(appending clauses: S) -> QueryChainBuilder<D, R> where S.Element == QueryClause {
private func queryChain<S: Sequence>(appending clauses: S) -> QueryChainBuilder<O, R> 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<T>(_ keyPath: KeyPath<D, T>) -> QueryChainBuilder<D, R> {
public func groupBy<T>(_ keyPath: KeyPath<O, T>) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>(keyPath))
return self.groupBy(GroupBy<O>(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`<T: AnyWhereClause>(_ clause: (D) -> T) -> QueryChainBuilder<D, R> {
public func `where`<T: AnyWhereClause>(_ clause: (O) -> T) -> QueryChainBuilder<O, R> {
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<T>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<T>>) -> QueryChainBuilder<D, R> {
public func groupBy<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>(keyPath))
return self.groupBy(GroupBy<O>(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<T>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) -> QueryChainBuilder<D, R> {
public func groupBy<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>(keyPath))
return self.groupBy(GroupBy<O>(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<T>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) -> QueryChainBuilder<D, R> {
public func groupBy<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>(keyPath))
return self.groupBy(GroupBy<O>(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<T>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) -> QueryChainBuilder<D, R> {
public func groupBy<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> QueryChainBuilder<O, R> {
return self.groupBy(GroupBy<D>(keyPath))
return self.groupBy(GroupBy<O>(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<D>) -> SectionMonitorChainBuilder<D> {
public func `where`(_ clause: Where<O>) -> SectionMonitorChainBuilder<O> {
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<D> {
public func `where`(format: String, _ args: Any...) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: Where<D>(format, argumentArray: args))
return self.sectionMonitorChain(appending: Where<O>(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<D> {
public func `where`(format: String, argumentArray: [Any]?) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: Where<D>(format, argumentArray: argumentArray))
return self.sectionMonitorChain(appending: Where<O>(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<D>) -> SectionMonitorChainBuilder<D> {
public func orderBy(_ clause: OrderBy<O>) -> SectionMonitorChainBuilder<O> {
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<D>.SortKey, _ sortKeys: OrderBy<D>.SortKey...) -> SectionMonitorChainBuilder<D> {
public func orderBy(_ sortKey: OrderBy<O>.SortKey, _ sortKeys: OrderBy<O>.SortKey...) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: OrderBy<D>([sortKey] + sortKeys))
return self.sectionMonitorChain(appending: OrderBy<O>([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<D>.SortKey]) -> SectionMonitorChainBuilder<D> {
public func orderBy(_ sortKeys: [OrderBy<O>.SortKey]) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: OrderBy<D>(sortKeys))
return self.sectionMonitorChain(appending: OrderBy<O>(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<NSFetchRequestResult>) -> Void) -> SectionMonitorChainBuilder<D> {
public func tweak(_ fetchRequest: @escaping (NSFetchRequest<NSFetchRequestResult>) -> Void) -> SectionMonitorChainBuilder<O> {
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<D> {
public func appending(_ clause: FetchClause) -> SectionMonitorChainBuilder<O> {
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<S: Sequence>(contentsOf clauses: S) -> SectionMonitorChainBuilder<D> where S.Element == FetchClause {
public func appending<S: Sequence>(contentsOf clauses: S) -> SectionMonitorChainBuilder<O> where S.Element == FetchClause {
return self.sectionMonitorChain(appending: clauses)
}
@@ -940,7 +940,7 @@ extension SectionMonitorChainBuilder {
// MARK: Private
private func sectionMonitorChain(appending clause: FetchClause) -> SectionMonitorChainBuilder<D> {
private func sectionMonitorChain(appending clause: FetchClause) -> SectionMonitorChainBuilder<O> {
return .init(
from: self.from,
@@ -949,7 +949,7 @@ extension SectionMonitorChainBuilder {
)
}
private func sectionMonitorChain<S: Sequence>(appending clauses: S) -> SectionMonitorChainBuilder<D> where S.Element == FetchClause {
private func sectionMonitorChain<S: Sequence>(appending clauses: S) -> SectionMonitorChainBuilder<O> 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`<T: AnyWhereClause>(_ clause: (D) -> T) -> SectionMonitorChainBuilder<D> {
public func `where`<T: AnyWhereClause>(_ clause: (O) -> T) -> SectionMonitorChainBuilder<O> {
return self.sectionMonitorChain(appending: clause(D.meta))
return self.sectionMonitorChain(appending: clause(O.meta))
}
}

View File

@@ -39,12 +39,12 @@ import CoreData
let person = transaction.fetchOne(From<Person>("Configuration1"))
```
*/
public struct From<D: DynamicObject> {
public struct From<O: DynamicObject> {
/**
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<D: DynamicObject> {
*/
public init() {
self.init(entityClass: D.self, configurations: nil)
self.init(entityClass: O.self, configurations: nil)
}
/**
@@ -70,7 +70,7 @@ public struct From<D: DynamicObject> {
```
- 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<D: DynamicObject> {
*/
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<D: DynamicObject> {
*/
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<D: DynamicObject> {
- 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<D: DynamicObject> {
- 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<D: DynamicObject> {
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<D: DynamicObject> {
// 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<D: DynamicObject> {
}
}
}
// MARK: Deprecated
@available(*, deprecated, renamed: "O")
public typealias D = O
}

View File

@@ -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<D: DynamicObject>: GroupByClause, QueryClause, Hashable {
public struct GroupBy<O: DynamicObject>: GroupByClause, QueryClause, Hashable {
/**
Initializes a `GroupBy` clause with an empty list of key path strings
@@ -66,7 +66,7 @@ public struct GroupBy<D: DynamicObject>: GroupByClause, QueryClause, Hashable {
// MARK: GroupByClause
public typealias ObjectType = D
public typealias ObjectType = O
public let keyPaths: [KeyPathString]
@@ -101,31 +101,37 @@ public struct GroupBy<D: DynamicObject>: 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<T>(_ keyPath: KeyPath<D, T>) {
public init<T>(_ keyPath: KeyPath<O, T>) {
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<T>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<T>>) {
public init<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>) {
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<T>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) {
public init<T>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) {
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<T>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) {
public init<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) {
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<T>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) {
public init<T>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) {
self.init([D.meta[keyPath: keyPath].keyPath])
self.init([O.meta[keyPath: keyPath].keyPath])
}
}

View File

@@ -42,7 +42,7 @@ extension Internals {
internal let typedFetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>
@nonobjc
internal convenience init<D>(dataStack: DataStack, fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>, from: From<D>, sectionBy: SectionBy<D>? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>) -> Void) {
internal convenience init<O>(dataStack: DataStack, fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>, from: From<O>, sectionBy: SectionBy<O>? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>) -> Void) {
self.init(
context: dataStack.mainContext,
@@ -54,7 +54,7 @@ extension Internals {
}
@nonobjc
internal init<D>(context: NSManagedObjectContext, fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>, from: From<D>, sectionBy: SectionBy<D>? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>) -> Void) {
internal init<O>(context: NSManagedObjectContext, fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>, from: From<O>, sectionBy: SectionBy<O>? = nil, applyFetchClauses: @escaping (_ fetchRequest: Internals.CoreStoreFetchRequest<NSManagedObject>) -> Void) {
_ = try? from.applyToFetchRequest(
fetchRequest,

View File

@@ -39,12 +39,12 @@ import CoreData
let person = transaction.create(Into<MyPersonEntity>("Configuration1"))
```
*/
public struct Into<D: DynamicObject>: Hashable {
public struct Into<O: DynamicObject>: 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<D: DynamicObject>: 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<D: DynamicObject>: 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<D: DynamicObject>: 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<D: DynamicObject>: 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<D: DynamicObject>: 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
}

View File

@@ -42,7 +42,7 @@ extension DataStack {
- returns: an `NSFetchedResultsController` that observes the `DataStack`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.mainContext,
@@ -62,7 +62,7 @@ extension DataStack {
- returns: an `NSFetchedResultsController` that observes the `DataStack`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.mainContext,
@@ -81,7 +81,7 @@ extension DataStack {
- returns: an `NSFetchedResultsController` that observes the `DataStack`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.mainContext,
@@ -100,7 +100,7 @@ extension DataStack {
- returns: an `NSFetchedResultsController` that observes the `DataStack`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(forDataStack dataStack: DataStack, _ from: From<D>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(forDataStack dataStack: DataStack, _ from: From<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.mainContext,
@@ -127,7 +127,7 @@ extension UnsafeDataTransaction {
- returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.context,
@@ -147,7 +147,7 @@ extension UnsafeDataTransaction {
- returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.context,
@@ -166,7 +166,7 @@ extension UnsafeDataTransaction {
- returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ fetchClauses: FetchClause...) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.context,
@@ -185,7 +185,7 @@ extension UnsafeDataTransaction {
- returns: an `NSFetchedResultsController` that observes the `UnsafeDataTransaction`
*/
@nonobjc
public func createFetchedResultsController<D: NSManagedObject>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<D> {
public func createFetchedResultsController<O: NSManagedObject>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
return Internals.createFRC(
fromContext: self.context,
@@ -205,7 +205,7 @@ extension Internals {
// MARK: FilePrivate
@available(macOS 10.12, *)
fileprivate static func createFRC<D: NSManagedObject>(fromContext context: NSManagedObjectContext, from: From<D>, sectionBy: SectionBy<D>? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController<D> {
fileprivate static func createFRC<O: NSManagedObject>(fromContext context: NSManagedObjectContext, from: From<O>, sectionBy: SectionBy<O>? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
let controller = Internals.CoreStoreFetchedResultsController(
context: context,
@@ -218,7 +218,7 @@ extension Internals {
Internals.assert(
fetchRequest.sortDescriptors?.isEmpty == false,
"An \(Internals.typeName(NSFetchedResultsController<D>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<D>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
"An \(Internals.typeName(NSFetchedResultsController<O>.self)) requires a sort information. Specify from a \(Internals.typeName(OrderBy<O>.self)) clause or any custom \(Internals.typeName(FetchClause.self)) that provides a sort descriptor."
)
}
)

View File

@@ -87,9 +87,9 @@ extension NSManagedObjectContext {
}
@nonobjc
internal func objectPublisher<D: DynamicObject>(objectID: NSManagedObjectID) -> ObjectPublisher<D> {
internal func objectPublisher<O: DynamicObject>(objectID: NSManagedObjectID) -> ObjectPublisher<O> {
let cache: NSMapTable<NSManagedObjectID, ObjectPublisher<D>> = self.userInfo(for: .objectPublishersCache(D.self)) {
let cache: NSMapTable<NSManagedObjectID, ObjectPublisher<O>> = self.userInfo(for: .objectPublishersCache(O.self)) {
return .strongToWeakObjects()
}
@@ -99,7 +99,7 @@ extension NSManagedObjectContext {
return objectPublisher
}
let objectPublisher = ObjectPublisher<D>(objectID: objectID, context: self)
let objectPublisher = ObjectPublisher<O>(objectID: objectID, context: self)
cache.setObject(objectPublisher, forKey: objectID)
return objectPublisher
}

View File

@@ -34,7 +34,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
// MARK: FetchableSource
@nonobjc
public func fetchExisting<D: DynamicObject>(_ object: D) -> D? {
public func fetchExisting<O: DynamicObject>(_ object: O) -> O? {
let rawObject = object.cs_toRaw()
if rawObject.objectID.isTemporaryID {
@@ -75,12 +75,12 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchExisting<D: DynamicObject>(_ objectID: NSManagedObjectID) -> D? {
public func fetchExisting<O: DynamicObject>(_ 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<D: DynamicObject, S: Sequence>(_ objects: S) -> [D] where S.Iterator.Element == D {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ objects: S) -> [O] where S.Iterator.Element == O {
return objects.compactMap({ self.fetchExisting($0.cs_id()) })
}
@nonobjc
public func fetchExisting<D: DynamicObject, S: Sequence>(_ objectIDs: S) -> [D] where S.Iterator.Element == NSManagedObjectID {
public func fetchExisting<O: DynamicObject, S: Sequence>(_ objectIDs: S) -> [O] where S.Iterator.Element == NSManagedObjectID {
return objectIDs.compactMap({ self.fetchExisting($0) })
}
@nonobjc
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ fetchClauses: FetchClause...) throws -> O? {
return try self.fetchOne(from, fetchClauses)
}
@nonobjc
public func fetchOne<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> D? {
public func fetchOne<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> O? {
let fetchRequest = Internals.CoreStoreFetchRequest<NSManagedObject>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -126,13 +126,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ fetchClauses: FetchClause...) throws -> [O] {
return try self.fetchAll(from, fetchClauses)
}
@nonobjc
public func fetchAll<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [D] {
public func fetchAll<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> [O] {
let fetchRequest = Internals.CoreStoreFetchRequest<NSManagedObject>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -152,13 +152,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ fetchClauses: FetchClause...) throws -> Int {
return try self.fetchCount(from, fetchClauses)
}
@nonobjc
public func fetchCount<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> Int {
public func fetchCount<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> Int {
let fetchRequest = Internals.CoreStoreFetchRequest<NSNumber>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -176,13 +176,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ fetchClauses: FetchClause...) throws -> NSManagedObjectID? {
return try self.fetchObjectID(from, fetchClauses)
}
@nonobjc
public func fetchObjectID<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
public func fetchObjectID<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> NSManagedObjectID? {
let fetchRequest = Internals.CoreStoreFetchRequest<NSManagedObjectID>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -201,13 +201,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ fetchClauses: FetchClause...) throws -> [NSManagedObjectID] {
return try self.fetchObjectIDs(from, fetchClauses)
}
@nonobjc
public func fetchObjectIDs<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
public func fetchObjectIDs<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) throws -> [NSManagedObjectID] {
let fetchRequest = Internals.CoreStoreFetchRequest<NSManagedObjectID>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -257,13 +257,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
// MARK: QueryableSource
@nonobjc
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ queryClauses: QueryClause...) throws -> U? {
return try self.queryValue(from, selectClause, queryClauses)
}
@nonobjc
public func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U? {
public func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ queryClauses: [QueryClause]) throws -> U? {
let fetchRequest = Internals.CoreStoreFetchRequest<NSDictionary>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -283,13 +283,13 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
}
@nonobjc
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]] {
return try self.queryAttributes(from, selectClause, queryClauses)
}
@nonobjc
public func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
public func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]] {
let fetchRequest = Internals.CoreStoreFetchRequest<NSDictionary>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -320,7 +320,7 @@ extension NSManagedObjectContext: FetchableSource, QueryableSource {
// MARK: Deleting
@nonobjc
internal func deleteAll<D>(_ from: From<D>, _ deleteClauses: [FetchClause]) throws -> Int {
internal func deleteAll<O>(_ from: From<O>, _ deleteClauses: [FetchClause]) throws -> Int {
let fetchRequest = Internals.CoreStoreFetchRequest<NSManagedObject>()
try from.applyToFetchRequest(fetchRequest, context: self)
@@ -343,9 +343,9 @@ extension NSManagedObjectContext {
// MARK: Fetching
@nonobjc
internal func fetchOne<D: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<D>) throws -> D? {
internal func fetchOne<O: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<O>) throws -> O? {
var fetchResults: [D]?
var fetchResults: [O]?
var fetchError: Error?
self.performAndWait {
@@ -371,9 +371,9 @@ extension NSManagedObjectContext {
}
@nonobjc
internal func fetchAll<D: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<D>) throws -> [D] {
internal func fetchAll<O: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<O>) 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<D, U: QueryableAttributeType>(_ selectTerms: [SelectTerm<D>], fetchRequest: Internals.CoreStoreFetchRequest<NSDictionary>) throws -> U? {
internal func queryValue<O, U: QueryableAttributeType>(_ selectTerms: [SelectTerm<O>], fetchRequest: Internals.CoreStoreFetchRequest<NSDictionary>) 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<D, U>.ReturnType.cs_fromQueryableNativeType(rawObject)
return Select<O, U>.ReturnType.cs_fromQueryableNativeType(rawObject)
}
return nil
}
@@ -491,7 +491,7 @@ extension NSManagedObjectContext {
}
@nonobjc
internal func queryValue<D>(_ selectTerms: [SelectTerm<D>], fetchRequest: Internals.CoreStoreFetchRequest<NSDictionary>) throws -> Any? {
internal func queryValue<O>(_ selectTerms: [SelectTerm<O>], fetchRequest: Internals.CoreStoreFetchRequest<NSDictionary>) throws -> Any? {
var fetchResults: [Any]?
var fetchError: Error?
@@ -555,7 +555,7 @@ extension NSManagedObjectContext {
// MARK: Deleting
@nonobjc
internal func deleteAll<D: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<D>) throws -> Int {
internal func deleteAll<O: NSManagedObject>(_ fetchRequest: Internals.CoreStoreFetchRequest<O>) throws -> Int {
var numberOfDeletedObjects: Int?
var fetchError: Error?

View File

@@ -32,7 +32,7 @@ import CoreData
/**
The `OrderBy` clause specifies the sort order for results for a fetch or a query.
*/
public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause, DeleteClause, Hashable {
public struct OrderBy<O: DynamicObject>: OrderByClause, FetchClause, QueryClause, DeleteClause, Hashable {
/**
Combines two `OrderBy` sort descriptors together
@@ -102,7 +102,7 @@ public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause
// MARK: OrderByClause
public typealias ObjectType = D
public typealias ObjectType = O
public let sortDescriptors: [NSSortDescriptor]
@@ -170,7 +170,7 @@ public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause
/**
Indicates that the `KeyPathString` should be sorted in ascending order
*/
public static func ascending<T>(_ keyPath: KeyPath<D, T>) -> SortKey where D: NSManagedObject {
public static func ascending<T>(_ keyPath: KeyPath<O, T>) -> SortKey where O: NSManagedObject {
return .ascending(keyPath._kvcKeyPathString!)
}
@@ -178,7 +178,7 @@ public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause
/**
Indicates that the `KeyPathString` should be sorted in descending order
*/
public static func descending<T>(_ keyPath: KeyPath<D, T>) -> SortKey where D: NSManagedObject {
public static func descending<T>(_ keyPath: KeyPath<O, T>) -> SortKey where O: NSManagedObject {
return .descending(keyPath._kvcKeyPathString!)
}
@@ -189,65 +189,65 @@ public struct OrderBy<D: DynamicObject>: OrderByClause, FetchClause, QueryClause
/**
Indicates that the `KeyPathString` should be sorted in ascending order
*/
public static func ascending<T>(_ attribute: KeyPath<D, ValueContainer<D>.Required<T>>) -> SortKey {
public static func ascending<T>(_ attribute: KeyPath<O, ValueContainer<O>.Required<T>>) -> 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<T>(_ attribute: KeyPath<D, ValueContainer<D>.Optional<T>>) -> SortKey {
public static func ascending<T>(_ attribute: KeyPath<O, ValueContainer<O>.Optional<T>>) -> 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<T>(_ attribute: KeyPath<D, TransformableContainer<D>.Required<T>>) -> SortKey {
public static func ascending<T>(_ attribute: KeyPath<O, TransformableContainer<O>.Required<T>>) -> 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<T>(_ attribute: KeyPath<D, TransformableContainer<D>.Optional<T>>) -> SortKey {
public static func ascending<T>(_ attribute: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> 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<T>(_ attribute: KeyPath<D, ValueContainer<D>.Required<T>>) -> SortKey {
public static func descending<T>(_ attribute: KeyPath<O, ValueContainer<O>.Required<T>>) -> 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<T>(_ attribute: KeyPath<D, ValueContainer<D>.Optional<T>>) -> SortKey {
public static func descending<T>(_ attribute: KeyPath<O, ValueContainer<O>.Optional<T>>) -> 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<T>(_ attribute: KeyPath<D, TransformableContainer<D>.Required<T>>) -> SortKey {
public static func descending<T>(_ attribute: KeyPath<O, TransformableContainer<O>.Required<T>>) -> 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<T>(_ attribute: KeyPath<D, TransformableContainer<D>.Optional<T>>) -> SortKey {
public static func descending<T>(_ attribute: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> SortKey {
return .descending(D.meta[keyPath: attribute].keyPath)
return .descending(O.meta[keyPath: attribute].keyPath)
}
@@ -255,27 +255,33 @@ public struct OrderBy<D: DynamicObject>: 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<K: KeyPathStringConvertible>(_ attribute: (D) -> K) -> OrderBy<D>.SortKey {
public static func ascending<K: KeyPathStringConvertible>(_ attribute: (O) -> K) -> OrderBy<O>.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<K: KeyPathStringConvertible>(_ attribute: (D) -> K) -> OrderBy<D>.SortKey {
public static func descending<K: KeyPathStringConvertible>(_ attribute: (O) -> K) -> OrderBy<O>.SortKey {
return .descending(attribute(D.meta).cs_keyPathString)
return .descending(attribute(O.meta).cs_keyPathString)
}
}

View File

@@ -39,16 +39,22 @@ import CoreData
)
```
*/
public struct QueryChainBuilder<D: DynamicObject, R: SelectResultType>: QueryChainableBuilderType {
public struct QueryChainBuilder<O: DynamicObject, R: SelectResultType>: QueryChainableBuilderType {
// MARK: QueryChainableBuilderType
public typealias ObjectType = D
public typealias ObjectType = O
public typealias ResultType = R
public var from: From<D>
public var select: Select<D, R>
public var from: From<O>
public var select: Select<O, R>
public var queryClauses: [QueryClause] = []
// MARK: Deprecated
@available(*, deprecated, renamed: "O")
public typealias D = O
}

View File

@@ -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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: QueryClause...) throws -> U?
func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
func queryValue<D, U: QueryableAttributeType>(_ from: From<D>, _ selectClause: Select<D, U>, _ queryClauses: [QueryClause]) throws -> U?
func queryValue<O, U: QueryableAttributeType>(_ from: From<O>, _ selectClause: Select<O, U>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: QueryClause...) throws -> [[String: Any]]
func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ 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<U>` parameter.
- throws: `CoreStoreError.persistentStoreNotFound` if the specified entity could not be found in any store's schema.
*/
func queryAttributes<D>(_ from: From<D>, _ selectClause: Select<D, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]]
func queryAttributes<O>(_ from: From<O>, _ selectClause: Select<O, NSDictionary>, _ queryClauses: [QueryClause]) throws -> [[String: Any]]
/**
Queries a dictionary of attribute values or as specified by the `QueryChainableBuilderType` built from a chain of clauses.

View File

@@ -40,7 +40,7 @@ import CoreData
```
*/
@available(macOS 10.12, *)
public struct SectionBy<D: DynamicObject> {
public struct SectionBy<O: DynamicObject> {
/**
Initializes a `SectionBy` clause with the key path to use to group `ListMonitor` objects into sections
@@ -70,17 +70,23 @@ public struct SectionBy<D: DynamicObject> {
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<T>(_ sectionKeyPath: KeyPath<D, T>) {
public init<T>(_ sectionKeyPath: KeyPath<O, T>) {
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<T>(_ sectionKeyPath: KeyPath<D, T>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
public init<T>(_ sectionKeyPath: KeyPath<O, T>, _ 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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>) {
public init<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>) {
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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>) {
public init<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>) {
public init<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) {
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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>) {
public init<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) {
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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
public init<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>, _ 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<T>(_ sectionKeyPath: KeyPath<D, ValueContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
public init<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>, _ 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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Required<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
public init<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>, _ 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<T>(_ sectionKeyPath: KeyPath<D, TransformableContainer<D>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
public init<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
self.init(D.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer)
self.init(O.meta[keyPath: sectionKeyPath].keyPath, sectionIndexTransformer)
}
}

View File

@@ -41,13 +41,19 @@ import CoreData
```
*/
@available(macOS 10.12, *)
public struct SectionMonitorChainBuilder<D: DynamicObject>: SectionMonitorBuilderType {
public struct SectionMonitorChainBuilder<O: DynamicObject>: SectionMonitorBuilderType {
// MARK: SectionMonitorBuilderType
public var from: From<D>
public var sectionBy: SectionBy<D>
public var from: From<O>
public var sectionBy: SectionBy<O>
public var fetchClauses: [FetchClause] = []
// MARK: Deprecated
@available(*, deprecated, renamed: "O")
public typealias D = O
}

View File

@@ -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<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
public enum SelectTerm<O: DynamicObject>: 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<D: DynamicObject>: 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<D> {
public static func attribute(_ keyPath: KeyPathString) -> SelectTerm<O> {
return ._attribute(keyPath)
}
@@ -91,7 +91,7 @@ public enum SelectTerm<D: DynamicObject>: 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(<attributeName>)" 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<D> {
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._aggregate(
function: "average:",
@@ -113,7 +113,7 @@ public enum SelectTerm<D: DynamicObject>: 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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._aggregate(
function: "count:",
@@ -135,7 +135,7 @@ public enum SelectTerm<D: DynamicObject>: 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(<attributeName>)" 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<D> {
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._aggregate(
function: "max:",
@@ -157,7 +157,7 @@ public enum SelectTerm<D: DynamicObject>: 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(<attributeName>)" 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<D> {
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._aggregate(
function: "min:",
@@ -179,7 +179,7 @@ public enum SelectTerm<D: DynamicObject>: 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(<attributeName>)" 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<D> {
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._aggregate(
function: "sum:",
@@ -202,7 +202,7 @@ public enum SelectTerm<D: DynamicObject>: 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<D> {
public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm<O> {
return ._identity(
alias: alias ?? "objectID",
@@ -231,7 +231,7 @@ public enum SelectTerm<D: DynamicObject>: ExpressibleByStringLiteral, Hashable {
// MARK: Equatable
public static func == (lhs: SelectTerm<D>, rhs: SelectTerm<D>) -> Bool {
public static func == (lhs: SelectTerm<O>, rhs: SelectTerm<O>) -> Bool {
switch (lhs, rhs) {
@@ -296,19 +296,25 @@ public enum SelectTerm<D: DynamicObject>: 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<V>(_ keyPath: KeyPath<D, V>) -> SelectTerm<D> {
public static func attribute<V>(_ keyPath: KeyPath<O, V>) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func average<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func maximum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func minimum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum<V>(_ keyPath: KeyPath<D, V>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func sum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>) -> SelectTerm<D> {
public static func attribute<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>) -> SelectTerm<O> {
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<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>) -> SelectTerm<D> {
public static func attribute<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>) -> SelectTerm<O> {
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<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>) -> SelectTerm<D> {
public static func attribute<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>) -> SelectTerm<O> {
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<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>) -> SelectTerm<D> {
public static func attribute<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func average<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func average<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func average<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
*/
public static func average<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func average<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count<V>(_ keyPath: KeyPath<D,
ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count<V>(_ keyPath: KeyPath<O,
ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count<V>(_ keyPath: KeyPath<D,
ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count<V>(_ keyPath: KeyPath<O,
ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count<V>(_ keyPath: KeyPath<D,
TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count<V>(_ keyPath: KeyPath<O,
TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for a count query
*/
public static func count<V>(_ keyPath: KeyPath<D,
TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func count<V>(_ keyPath: KeyPath<O,
TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum<V>(_ keyPath: KeyPath<D,
ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func maximum<V>(_ keyPath: KeyPath<O,
ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum<V>(_ keyPath: KeyPath<D,
ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func maximum<V>(_ keyPath: KeyPath<O,
ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum<V>(_ keyPath: KeyPath<D,
TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func maximum<V>(_ keyPath: KeyPath<O,
TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
*/
public static func maximum<V>(_ keyPath: KeyPath<D,
TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func maximum<V>(_ keyPath: KeyPath<O,
TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func minimum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func minimum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func minimum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
*/
public static func minimum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func minimum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func sum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func sum<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func sum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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(<attributeName>)" is used
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
*/
public static func sum<V>(_ keyPath: KeyPath<D, TransformableContainer<D>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<D> {
public static func sum<V>(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<V>>, as alias: KeyPathString? = nil) -> SelectTerm<O> {
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<D: DynamicObject, T: SelectResultType>: SelectClause, Hashable {
public struct Select<O: DynamicObject, T: SelectResultType>: SelectClause, Hashable {
/**
Initializes a `Select` clause with a list of `SelectTerm`s
@@ -680,7 +686,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
- parameter selectTerm: a `SelectTerm`
- parameter selectTerms: a series of `SelectTerm`s
*/
public init(_ selectTerm: SelectTerm<D>, _ selectTerms: SelectTerm<D>...) {
public init(_ selectTerm: SelectTerm<O>, _ selectTerms: SelectTerm<O>...) {
self.selectTerms = [selectTerm] + selectTerms
}
@@ -690,7 +696,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
- parameter selectTerms: a series of `SelectTerm`s
*/
public init(_ selectTerms: [SelectTerm<D>]) {
public init(_ selectTerms: [SelectTerm<O>]) {
self.selectTerms = selectTerms
}
@@ -698,7 +704,7 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
// MARK: Equatable
public static func == <T, U>(lhs: Select<D, T>, rhs: Select<D, U>) -> Bool {
public static func == <T, U>(lhs: Select<O, T>, rhs: Select<O, U>) -> Bool {
return lhs.selectTerms == rhs.selectTerms
}
@@ -706,10 +712,10 @@ public struct Select<D: DynamicObject, T: SelectResultType>: SelectClause, Hasha
// MARK: SelectClause
public typealias ObjectType = D
public typealias ObjectType = O
public typealias ReturnType = T
public let selectTerms: [SelectTerm<D>]
public let selectTerms: [SelectTerm<O>]
// MARK: Hashable
@@ -806,6 +812,12 @@ public struct Select<D: DynamicObject, T: SelectResultType>: 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<D, T>) {
public init(_ keyPath: KeyPath<O, T>) {
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<D, ValueContainer<D>.Required<T>>) {
public init(_ keyPath: KeyPath<O, ValueContainer<O>.Required<T>>) {
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<D, ValueContainer<D>.Optional<T>>) {
public init(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) {
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<D, TransformableContainer<D>.Required<T>>) {
public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) {
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<D, TransformableContainer<D>.Optional<T>>) {
public init(_ keyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) {
self.init(.attribute(keyPath))
}

View File

@@ -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<D>(_ into: Into<D>) -> D {
public override func create<O>(_ into: Into<O>) -> 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<D: DynamicObject>(_ object: D?) -> D? {
public override func edit<O: DynamicObject>(_ 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<D>(_ into: Into<D>, _ objectID: NSManagedObjectID) -> D? {
public override func edit<O>(_ into: Into<O>, _ objectID: NSManagedObjectID) -> O? {
Internals.assert(
!self.isCommitted,

View File

@@ -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<D>(_ from: From<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public func monitorList<O>(_ from: From<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public func monitorList<O>(_ from: From<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
Internals.assert(
fetchClauses.filter { $0 is OrderBy<D> }.count > 0,
fetchClauses.filter { $0 is OrderBy<O> }.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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: FetchClause...) {
public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ fetchClauses: [FetchClause]) {
public func monitorList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ fetchClauses: [FetchClause]) {
Internals.assert(
fetchClauses.filter { $0 is OrderBy<D> }.count > 0,
fetchClauses.filter { $0 is OrderBy<O> }.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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) -> ListMonitor<D> {
public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: FetchClause...) -> ListMonitor<O> {
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<D>(_ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) -> ListMonitor<D> {
public func monitorSectionedList<O>(_ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) -> ListMonitor<O> {
Internals.assert(
fetchClauses.filter { $0 is OrderBy<D> }.count > 0,
fetchClauses.filter { $0 is OrderBy<O> }.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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: FetchClause...) {
public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ 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<D>(createAsynchronously: @escaping (ListMonitor<D>) -> Void, _ from: From<D>, _ sectionBy: SectionBy<D>, _ fetchClauses: [FetchClause]) {
public func monitorSectionedList<O>(createAsynchronously: @escaping (ListMonitor<O>) -> Void, _ from: From<O>, _ sectionBy: SectionBy<O>, _ fetchClauses: [FetchClause]) {
Internals.assert(
fetchClauses.filter { $0 is OrderBy<D> }.count > 0,
fetchClauses.filter { $0 is OrderBy<O> }.count > 0,
"A ListMonitor requires an OrderBy clause."
)

View File

@@ -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<Pet>().where((\.master ~ \.name) == "John"))
```
*/
public func ~<D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> {
public func ~<O: NSManagedObject, D: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<O, D>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.SingleTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -144,7 +150,7 @@ public func ~<D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPat
let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.SingleTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, V: AllowedObjectiveCKeyPathValue>(_ lhs: KeyPath<O, D?>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.SingleTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -155,7 +161,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCKeyPa
let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<O, D>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.CollectionTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -166,7 +172,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToMan
let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<D, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: KeyPath<O, D?>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.CollectionTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -177,7 +183,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, V: AllowedObjectiveCToMan
let johnsSonInLaw = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John"))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<O>.Expression<T, D>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<T, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -188,7 +194,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKe
let johnsSonInLaw = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.name) == "John"))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<T, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, T, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<O>.Expression<T, D?>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<T, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -199,7 +205,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCKe
let spouseHasSiblings = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<O>.Expression<T, D>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.CollectionTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -210,7 +216,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCTo
let spouseHasSiblings = dataStack.fetchOne(From<Person>().where((\.spouse ~ \.father ~ \.children).count() > 0))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, T, V: AllowedObjectiveCToManyRelationshipKeyPathValue>(_ lhs: Where<O>.Expression<T, D?>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.CollectionTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -221,7 +227,7 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, V: AllowedObjectiveCTo
let spousesWithBadNamingSense = dataStack.fetchAll(From<Person>().where((\.spouse ~ \.pets ~ \.name).any() == "Spot"))
```
*/
public func ~ <D: NSManagedObject, O: NSManagedObject, T, C: AllowedObjectiveCToManyRelationshipKeyPathValue, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<D>.Expression<T, C>, _ rhs: KeyPath<O, V>) -> Where<D>.Expression<Where<D>.CollectionTarget, V> {
public func ~ <O: NSManagedObject, D: NSManagedObject, T, C: AllowedObjectiveCToManyRelationshipKeyPathValue, V: AllowedObjectiveCKeyPathValue>(_ lhs: Where<O>.Expression<T, C>, _ rhs: KeyPath<D, V>) -> Where<O>.Expression<Where<O>.CollectionTarget, V> {
return .init(lhs.cs_keyPathString, rhs.cs_keyPathString)
}
@@ -235,11 +241,11 @@ public func ~ <D: NSManagedObject, O: NSManagedObject, T, C: AllowedObjectiveCTo
let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: KeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.SingleTarget, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, K: KeyPathStringConvertible>(_ lhs: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<Where<O>.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 ~ <D: CoreStoreObject, O: CoreStoreObject, K: KeyPathStringConvertib
let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<O>.Expression<T, D>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<T, K.DestinationValueType> 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 ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConver
let owner = dataStack.fetchOne(From<Pet>().where((\.master ~ \.name) == "John"))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<T, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, T, K: KeyPathStringConvertible>(_ lhs: Where<O>.Expression<T, D?>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<T, K.DestinationValueType> 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 ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: KeyPathStringConver
let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<Where<O>.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 ~ <D: CoreStoreObject, O: CoreStoreObject, K: ToManyRelationshipKeyP
let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<O>.Expression<T, D>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<Where<O>.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 ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipK
let happyPets = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets).count() > 1))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, O?>, _ rhs: KeyPath<O, K>) -> Where<D>.Expression<Where<D>.CollectionTarget, K.DestinationValueType> where K.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, T, K: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<O>.Expression<T, D?>, _ rhs: KeyPath<D, K>) -> Where<O>.Expression<Where<O>.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 ~ <D: CoreStoreObject, O: CoreStoreObject, T, K: ToManyRelationshipK
let spousesWithBadNamingSense = dataStack.fetchAll(From<Pet>().where((\.master ~ \.pets ~ \.name).any() == "Spot"))
```
*/
public func ~ <D: CoreStoreObject, O: CoreStoreObject, T, KC: ToManyRelationshipKeyPathStringConvertible, KV: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<D>.Expression<T, KC>, _ rhs: KeyPath<O, KV>) -> Where<D>.Expression<Where<D>.CollectionTarget, KV.DestinationValueType> where KC.ObjectType == D, KV.ObjectType == O {
public func ~ <O: CoreStoreObject, D: CoreStoreObject, T, KC: ToManyRelationshipKeyPathStringConvertible, KV: ToManyRelationshipKeyPathStringConvertible>(_ lhs: Where<O>.Expression<T, KC>, _ rhs: KeyPath<D, KV>) -> Where<O>.Expression<Where<O>.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 ~ <D: CoreStoreObject, O: CoreStoreObject, T, KC: ToManyRelationship
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
```
*/
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func == <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -347,9 +353,9 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
```
*/
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func != <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return !Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return !Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -358,9 +364,9 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name))
```
*/
public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V>) -> Where<D> where S.Iterator.Element == V {
public func ~= <O, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<O>.Expression<T, V>) -> Where<O> where S.Iterator.Element == V {
return Where<D>(expression.cs_keyPathString, isMemberOf: sequence)
return Where<O>(expression.cs_keyPathString, isMemberOf: sequence)
}
@@ -372,9 +378,9 @@ public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ e
let lonelyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() < 2))
```
*/
public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func < <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: "<", operand: rhs)
return Where<O>(expression: lhs, function: "<", operand: rhs)
}
/**
@@ -383,9 +389,9 @@ public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
let lonelyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() <= 1)
```
*/
public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func <= <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: "<=", operand: rhs)
return Where<O>(expression: lhs, function: "<=", operand: rhs)
}
/**
@@ -394,9 +400,9 @@ public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
let happyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() > 1)
```
*/
public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func > <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: ">", operand: rhs)
return Where<O>(expression: lhs, function: ">", operand: rhs)
}
/**
@@ -405,9 +411,9 @@ public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
let happyDog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.pets).count() >= 2)
```
*/
public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V>, _ rhs: V) -> Where<D> {
public func >= <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: ">=", operand: rhs)
return Where<O>(expression: lhs, function: ">=", operand: rhs)
}
@@ -419,9 +425,9 @@ public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
```
*/
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
public func == <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V) -> Where<O> {
return Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -430,9 +436,9 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) == "John"))
```
*/
public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
public func == <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V?) -> Where<O> {
return Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -441,9 +447,9 @@ public func == <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
```
*/
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
public func != <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V) -> Where<O> {
return !Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return !Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -452,9 +458,9 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where((\.master ~ \.name) != "John"))
```
*/
public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
public func != <O, T, V: QueryableAttributeType>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V?) -> Where<O> {
return !Where<D>(lhs.cs_keyPathString, isEqualTo: rhs)
return !Where<O>(lhs.cs_keyPathString, isEqualTo: rhs)
}
/**
@@ -463,9 +469,9 @@ public func != <D, T, V: QueryableAttributeType>(_ lhs: Where<D>.Expression<T, V
let dog = dataStack.fetchOne(From<Dog>().where(["John", "Joe"] ~= (\.master ~ \.name))
```
*/
public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<D>.Expression<T, V?>) -> Where<D> where S.Iterator.Element == V {
public func ~= <O, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ expression: Where<O>.Expression<T, V?>) -> Where<O> where S.Iterator.Element == V {
return Where<D>(expression.cs_keyPathString, isMemberOf: sequence)
return Where<O>(expression.cs_keyPathString, isMemberOf: sequence)
}
@@ -477,9 +483,9 @@ public func ~= <D, T, V: QueryableAttributeType, S: Sequence>(_ sequence: S, _ e
let childsPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) < 10))
```
*/
public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
public func < <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: "<", operand: rhs)
return Where<O>(expression: lhs, function: "<", operand: rhs)
}
/**
@@ -488,9 +494,9 @@ public func < <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
let childsPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) <= 10))
```
*/
public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
public func <= <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V?) -> Where<O> {
return Where<D>(expression: lhs, function: "<=", operand: rhs)
return Where<O>(expression: lhs, function: "<=", operand: rhs)
}
/**
@@ -499,9 +505,9 @@ public func <= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Ex
let teensPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) > 10))
```
*/
public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V) -> Where<D> {
public func > <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V) -> Where<O> {
return Where<D>(expression: lhs, function: ">", operand: rhs)
return Where<O>(expression: lhs, function: ">", operand: rhs)
}
/**
@@ -510,9 +516,9 @@ public func > <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Exp
let teensPet = dataStack.fetchOne(From<Dog>().where((\.master ~ \.age) >= 10))
```
*/
public func >= <D, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<D>.Expression<T, V?>, _ rhs: V?) -> Where<D> {
public func >= <O, T, V: QueryableAttributeType & Comparable>(_ lhs: Where<O>.Expression<T, V?>, _ rhs: V?) -> Where<O> {
return Where<D>(expression: lhs, function: ">=", operand: rhs)
return Where<O>(expression: lhs, function: ">=", operand: rhs)
}
@@ -532,9 +538,9 @@ extension KeyPath where Root: NSManagedObject, Value: AllowedObjectiveCToManyRel
}
}
// MARK: - Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue
// MARK: - Where.Expression where O: NSManagedObject, T == Where<O>.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue
extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue {
extension Where.Expression where O: NSManagedObject, T == Where<O>.CollectionTarget, V: AllowedObjectiveCToManyRelationshipKeyPathValue {
/**
Creates a `Where.Expression` clause for COUNT
@@ -542,16 +548,16 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
```
*/
public func count() -> Where<D>.Expression<T, Int> {
public func count() -> Where<O>.Expression<T, Int> {
return .init(self.cs_keyPathString, "@count")
}
}
// MARK: - Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCKeyPathValue
// MARK: - Where.Expression where O: NSManagedObject, T == Where<O>.CollectionTarget, V: AllowedObjectiveCKeyPathValue
extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTarget, V: AllowedObjectiveCKeyPathValue {
extension Where.Expression where O: NSManagedObject, T == Where<O>.CollectionTarget, V: AllowedObjectiveCKeyPathValue {
/**
Creates a `Where.Expression` clause for ANY
@@ -559,7 +565,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
let dogsWithBadNamingSense = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
```
*/
public func any() -> Where<D>.Expression<T, V> {
public func any() -> Where<O>.Expression<T, V> {
return .init("ANY " + self.cs_keyPathString)
}
@@ -570,7 +576,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
let allPlaymatePuppies = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))
```
*/
public func all() -> Where<D>.Expression<T, V> {
public func all() -> Where<O>.Expression<T, V> {
return .init("ALL " + self.cs_keyPathString)
}
@@ -581,7 +587,7 @@ extension Where.Expression where D: NSManagedObject, T == Where<D>.CollectionTar
let dogs = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
```
*/
public func none() -> Where<D>.Expression<T, V> {
public func none() -> Where<O>.Expression<T, V> {
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<D>.CollectionTarget
// MARK: - Where.Expression where O: CoreStoreObject, T == Where<O>.CollectionTarget
extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTarget {
extension Where.Expression where O: CoreStoreObject, T == Where<O>.CollectionTarget {
/**
Creates a `Where.Expression` clause for COUNT
@@ -615,7 +621,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
let dogsWithPlaymates = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets).count() > 1))
```
*/
public func count() -> Where<D>.Expression<T, Int> {
public func count() -> Where<O>.Expression<T, Int> {
return .init(self.cs_keyPathString, "@count")
}
@@ -626,7 +632,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
let dogsWithBadNamingSense = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
```
*/
public func any() -> Where<D>.Expression<T, V> {
public func any() -> Where<O>.Expression<T, V> {
return .init("ANY " + self.cs_keyPathString)
}
@@ -637,7 +643,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
let allPlaymatePuppies = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.age).all() > 5))
```
*/
public func all() -> Where<D>.Expression<T, V> {
public func all() -> Where<O>.Expression<T, V> {
return .init("ALL " + self.cs_keyPathString)
}
@@ -648,7 +654,7 @@ extension Where.Expression where D: CoreStoreObject, T == Where<D>.CollectionTar
let dogs = dataStack.fetchAll(From<Dog>().where((\.master ~ \.pets ~ \.name).any() > "Spot"))
```
*/
public func none() -> Where<D>.Expression<T, V> {
public func none() -> Where<O>.Expression<T, V> {
return .init("NONE " + self.cs_keyPathString)
}
@@ -661,17 +667,17 @@ extension Where {
// MARK: FilePrivate
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<D>.Expression<T, V>, function: String, operand: V) {
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<O>.Expression<T, V>, function: String, operand: V) {
self.init("\(expression.cs_keyPathString) \(function) %@", operand.cs_toQueryableNativeType())
}
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<D>.Expression<T, V?>, function: String, operand: V) {
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<O>.Expression<T, V?>, function: String, operand: V) {
self.init("\(expression.cs_keyPathString) \(function) %@", operand.cs_toQueryableNativeType())
}
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<D>.Expression<T, V>, function: String, operand: V?) {
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<O>.Expression<T, V>, function: String, operand: V?) {
if let operand = operand {
@@ -683,7 +689,7 @@ extension Where {
}
}
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<D>.Expression<T, V?>, function: String, operand: V?) {
fileprivate init<T, V: QueryableAttributeType & Comparable>(expression: Where<O>.Expression<T, V?>, function: String, operand: V?) {
if let operand = operand {

View File

@@ -36,37 +36,37 @@ infix operator ||? : LogicalConjunctionPrecedence
/**
The `Where` clause specifies the conditions for a fetch or a query.
*/
public struct Where<D: DynamicObject>: WhereClauseType, FetchClause, QueryClause, DeleteClause, Hashable {
public struct Where<O: DynamicObject>: WhereClauseType, FetchClause, QueryClause, DeleteClause, Hashable {
/**
Combines two `Where` predicates together using `AND` operator
*/
public static func && (left: Where<D>, right: Where<D>) -> Where<D> {
public static func && (left: Where<O>, right: Where<O>) -> Where<O> {
return Where<D>(NSCompoundPredicate(type: .and, subpredicates: [left.predicate, right.predicate]))
return Where<O>(NSCompoundPredicate(type: .and, subpredicates: [left.predicate, right.predicate]))
}
/**
Combines two `Where` predicates together using `OR` operator
*/
public static func || (left: Where<D>, right: Where<D>) -> Where<D> {
public static func || (left: Where<O>, right: Where<O>) -> Where<O> {
return Where<D>(NSCompoundPredicate(type: .or, subpredicates: [left.predicate, right.predicate]))
return Where<O>(NSCompoundPredicate(type: .or, subpredicates: [left.predicate, right.predicate]))
}
/**
Inverts the predicate of a `Where` clause using `NOT` operator
*/
public static prefix func ! (clause: Where<D>) -> Where<D> {
public static prefix func ! (clause: Where<O>) -> Where<O> {
return Where<D>(NSCompoundPredicate(type: .not, subpredicates: [clause.predicate]))
return Where<O>(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<D>, right: Where<D>?) -> Where<D> {
public static func &&? (left: Where<O>, right: Where<O>?) -> Where<O> {
if let right = right {
@@ -79,7 +79,7 @@ public struct Where<D: DynamicObject>: 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<D>?, right: Where<D>) -> Where<D> {
public static func &&? (left: Where<O>?, right: Where<O>) -> Where<O> {
if let left = left {
@@ -92,7 +92,7 @@ public struct Where<D: DynamicObject>: 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<D>, right: Where<D>?) -> Where<D> {
public static func ||? (left: Where<O>, right: Where<O>?) -> Where<O> {
if let right = right {
@@ -105,7 +105,7 @@ public struct Where<D: DynamicObject>: 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<D>?, right: Where<D>) -> Where<D> {
public static func ||? (left: Where<O>?, right: Where<O>) -> Where<O> {
if let left = left {
@@ -127,7 +127,7 @@ public struct Where<D: DynamicObject>: WhereClauseType, FetchClause, QueryClause
- parameter clause: the existing `Where` clause.
*/
public init(_ clause: Where<D>) {
public init(_ clause: Where<O>) {
self.init(clause.predicate)
}
@@ -200,7 +200,7 @@ public struct Where<D: DynamicObject>: WhereClauseType, FetchClause, QueryClause
- parameter keyPath: the keyPath to compare with
- parameter object: the arguments for the `==` operator
*/
public init<D: DynamicObject>(_ keyPath: KeyPathString, isEqualTo object: D?) {
public init<O: DynamicObject>(_ keyPath: KeyPathString, isEqualTo object: O?) {
switch object {
@@ -269,7 +269,7 @@ public struct Where<D: DynamicObject>: WhereClauseType, FetchClause, QueryClause
// MARK: WhereClauseType
public typealias ObjectType = D
public typealias ObjectType = O
// MARK: FetchClause, QueryClause, DeleteClause
@@ -302,12 +302,18 @@ public struct Where<D: DynamicObject>: 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<V: QueryableAttributeType>(_ keyPath: KeyPath<D, V>, isEqualTo null: Void?) {
public init<V: QueryableAttributeType>(_ keyPath: KeyPath<O, V>, 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<O: DynamicObject>(_ keyPath: KeyPath<D, O>, isEqualTo null: Void?) {
public init<D: DynamicObject>(_ keyPath: KeyPath<O, D>, 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<V: QueryableAttributeType>(_ keyPath: KeyPath<D, V>, isEqualTo value: V?) {
public init<V: QueryableAttributeType>(_ keyPath: KeyPath<O, V>, 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<O: DynamicObject>(_ keyPath: KeyPath<D, O>, isEqualTo value: O?) {
public init<D: DynamicObject>(_ keyPath: KeyPath<O, D>, 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<O: DynamicObject>(_ keyPath: KeyPath<D, O>, isEqualTo objectID: NSManagedObjectID) {
public init<D: DynamicObject>(_ keyPath: KeyPath<O, D>, 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<V: QueryableAttributeType, S: Sequence>(_ keyPath: KeyPath<D, V>, isMemberOf list: S) where S.Iterator.Element == V {
public init<V: QueryableAttributeType, S: Sequence>(_ keyPath: KeyPath<O, V>, 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<O: DynamicObject, S: Sequence>(_ keyPath: KeyPath<D, O>, isMemberOf list: S) where S.Iterator.Element == O {
public init<D: DynamicObject, S: Sequence>(_ keyPath: KeyPath<O, D>, 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<O: DynamicObject, S: Sequence>(_ keyPath: KeyPath<D, O>, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID {
public init<D: DynamicObject, S: Sequence>(_ keyPath: KeyPath<D, O>, 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<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, isEqualTo null: Void?) {
public init<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, 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<O>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isEqualTo null: Void?) {
public init<D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, 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<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, isEqualTo value: V?) {
public init<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, 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<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, isEqualTo value: V?) {
public init<V>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, 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<O>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isEqualTo value: O?) {
public init<D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, 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<O>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isEqualTo objectID: NSManagedObjectID) {
public init<D>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, 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<V, S: Sequence>(_ keyPath: KeyPath<D, ValueContainer<D>.Required<V>>, isMemberOf list: S) where S.Iterator.Element == V {
public init<V, S: Sequence>(_ keyPath: KeyPath<O, ValueContainer<O>.Required<V>>, 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<V, S: Sequence>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, isMemberOf list: S) where S.Iterator.Element == V {
public init<V, S: Sequence>(_ keyPath: KeyPath<O, ValueContainer<O>.Optional<V>>, 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<O, S: Sequence>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isMemberOf list: S) where S.Iterator.Element == O {
public init<D, S: Sequence>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, 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<O, S: Sequence>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isMemberOf list: S) where S.Iterator.Element: NSManagedObjectID {
public init<D, S: Sequence>(_ keyPath: KeyPath<O, RelationshipContainer<O>.ToOne<D>>, 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<D>) {
public init(_ condition: (O) -> Where<O>) {
self = condition(D.meta)
self = condition(O.meta)
}
}