mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-10 11:23:39 +02:00
WIP: Query builders
This commit is contained in:
@@ -324,6 +324,10 @@
|
|||||||
B5519A601CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
B5519A601CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
||||||
B5519A611CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
B5519A611CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
||||||
B5519A621CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
B5519A621CA21954002BEF78 /* CSAsynchronousDataTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */; };
|
||||||
|
B55514EA1EED8BF900BAB888 /* FetchCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55514E91EED8BF900BAB888 /* FetchCondition.swift */; };
|
||||||
|
B55514EB1EED8BF900BAB888 /* FetchCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55514E91EED8BF900BAB888 /* FetchCondition.swift */; };
|
||||||
|
B55514EC1EED8BF900BAB888 /* FetchCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55514E91EED8BF900BAB888 /* FetchCondition.swift */; };
|
||||||
|
B55514ED1EED8BF900BAB888 /* FetchCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = B55514E91EED8BF900BAB888 /* FetchCondition.swift */; };
|
||||||
B55717441D15B09E009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
B55717441D15B09E009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
B55717451D15B09F009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
B55717451D15B09F009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
B55717461D15B0A1009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
B55717461D15B0A1009BDBCA /* CoreStoreBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@@ -786,6 +790,7 @@
|
|||||||
B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSAsynchronousDataTransaction.swift; sourceTree = "<group>"; };
|
B5519A5E1CA21954002BEF78 /* CSAsynchronousDataTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSAsynchronousDataTransaction.swift; sourceTree = "<group>"; };
|
||||||
B5548CD51BD65AE00077652A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
B5548CD51BD65AE00077652A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
B5548CD71BD65AE50077652A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
|
B5548CD71BD65AE50077652A /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
|
B55514E91EED8BF900BAB888 /* FetchCondition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchCondition.swift; sourceTree = "<group>"; };
|
||||||
B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreStoreBridge.h; sourceTree = "<group>"; };
|
B55717421D15AF9C009BDBCA /* CoreStoreBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreStoreBridge.h; sourceTree = "<group>"; };
|
||||||
B559CD421CAA8B6300E4D58B /* CSSetupResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSSetupResult.swift; sourceTree = "<group>"; };
|
B559CD421CAA8B6300E4D58B /* CSSetupResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSSetupResult.swift; sourceTree = "<group>"; };
|
||||||
B559CD481CAA8C6D00E4D58B /* CSStorageInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSStorageInterface.swift; sourceTree = "<group>"; };
|
B559CD481CAA8C6D00E4D58B /* CSStorageInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CSStorageInterface.swift; sourceTree = "<group>"; };
|
||||||
@@ -1374,6 +1379,7 @@
|
|||||||
B5E84F061AFF847B0064E85B /* DataStack+Querying.swift */,
|
B5E84F061AFF847B0064E85B /* DataStack+Querying.swift */,
|
||||||
B5E84F071AFF847B0064E85B /* CoreStore+Querying.swift */,
|
B5E84F071AFF847B0064E85B /* CoreStore+Querying.swift */,
|
||||||
B596BBB51DD5BC67001DCDD9 /* FetchableSource.swift */,
|
B596BBB51DD5BC67001DCDD9 /* FetchableSource.swift */,
|
||||||
|
B55514E91EED8BF900BAB888 /* FetchCondition.swift */,
|
||||||
B596BBBA1DD5C39F001DCDD9 /* QueryableSource.swift */,
|
B596BBBA1DD5C39F001DCDD9 /* QueryableSource.swift */,
|
||||||
B549F65D1E569C7400FBAB2D /* QueryableAttributeType.swift */,
|
B549F65D1E569C7400FBAB2D /* QueryableAttributeType.swift */,
|
||||||
B5E84F0A1AFF847B0064E85B /* Protocol Clauses */,
|
B5E84F0A1AFF847B0064E85B /* Protocol Clauses */,
|
||||||
@@ -1794,6 +1800,7 @@
|
|||||||
B5D339D81E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
B5D339D81E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B5D3F6451C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */,
|
B5D3F6451C887C0A00C7492A /* LegacySQLiteStore.swift in Sources */,
|
||||||
B56923FA1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
B56923FA1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
||||||
|
B55514EA1EED8BF900BAB888 /* FetchCondition.swift in Sources */,
|
||||||
B596BBBB1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBB1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDBFF1CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDBFF1CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
B5ECDC051CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
B5ECDC051CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
||||||
@@ -1980,6 +1987,7 @@
|
|||||||
B5D339D91E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
B5D339D91E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
82BA18CE1C4BBD7100A0916E /* FetchedResultsControllerDelegate.swift in Sources */,
|
82BA18CE1C4BBD7100A0916E /* FetchedResultsControllerDelegate.swift in Sources */,
|
||||||
B56923FB1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
B56923FB1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
||||||
|
B55514EB1EED8BF900BAB888 /* FetchCondition.swift in Sources */,
|
||||||
B596BBBC1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBC1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDC011CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDC011CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
B5ECDC071CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
B5ECDC071CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
||||||
@@ -2166,6 +2174,7 @@
|
|||||||
B5D339DB1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
B5D339DB1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B52DD1951BE1F92500949AFE /* CoreStoreError.swift in Sources */,
|
B52DD1951BE1F92500949AFE /* CoreStoreError.swift in Sources */,
|
||||||
B56923FD1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
B56923FD1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
||||||
|
B55514ED1EED8BF900BAB888 /* FetchCondition.swift in Sources */,
|
||||||
B596BBBE1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBE1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B546F9601C9A12B800D5AC55 /* CSSQliteStore.swift in Sources */,
|
B546F9601C9A12B800D5AC55 /* CSSQliteStore.swift in Sources */,
|
||||||
B5ECDC0F1CA8161B00C7F112 /* CSGroupBy.swift in Sources */,
|
B5ECDC0F1CA8161B00C7F112 /* CSGroupBy.swift in Sources */,
|
||||||
@@ -2352,6 +2361,7 @@
|
|||||||
B5D339DA1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
B5D339DA1E9489AB00C880DE /* CoreStoreObject.swift in Sources */,
|
||||||
B5ECDC021CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
B5ECDC021CA80CBA00C7F112 /* CSWhere.swift in Sources */,
|
||||||
B56923FC1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
B56923FC1EB82956007C4DC9 /* CSXcodeDataModelSchema.swift in Sources */,
|
||||||
|
B55514EC1EED8BF900BAB888 /* FetchCondition.swift in Sources */,
|
||||||
B596BBBD1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
B596BBBD1DD5C39F001DCDD9 /* QueryableSource.swift in Sources */,
|
||||||
B5ECDC081CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
B5ECDC081CA8138100C7F112 /* CSOrderBy.swift in Sources */,
|
||||||
B5E1B59B1CAA0C23007FD580 /* CSObjectObserver.swift in Sources */,
|
B5E1B59B1CAA0C23007FD580 /* CSObjectObserver.swift in Sources */,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class ObjectObserverDemoViewController: UIViewController, ObjectObserver {
|
|||||||
|
|
||||||
// MARK: ObjectObserver
|
// MARK: ObjectObserver
|
||||||
|
|
||||||
func objectMonitor(_ monitor: ObjectMonitor<Palette>, didUpdateObject object: Palette, changedPersistentKeys: Set<RawKeyPath>) {
|
func objectMonitor(_ monitor: ObjectMonitor<Palette>, didUpdateObject object: Palette, changedPersistentKeys: Set<KeyPathString>) {
|
||||||
|
|
||||||
self.reloadPaletteInfo(object, changedKeys: changedPersistentKeys)
|
self.reloadPaletteInfo(object, changedKeys: changedPersistentKeys)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class TransactionsDemoViewController: UIViewController, MKMapViewDelegate, Objec
|
|||||||
// none
|
// none
|
||||||
}
|
}
|
||||||
|
|
||||||
func objectMonitor(_ monitor: ObjectMonitor<Place>, didUpdateObject object: Place, changedPersistentKeys: Set<RawKeyPath>) {
|
func objectMonitor(_ monitor: ObjectMonitor<Place>, didUpdateObject object: Place, changedPersistentKeys: Set<KeyPathString>) {
|
||||||
|
|
||||||
if let mapView = self.mapView {
|
if let mapView = self.mapView {
|
||||||
|
|
||||||
|
|||||||
@@ -1447,7 +1447,7 @@ class MyViewController: UIViewController, ObjectObserver {
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
func objectMonitor(monitor: ObjectMonitor<MyPersonEntity>, didUpdateObject object: MyPersonEntity, changedPersistentKeys: Set<RawKeyPath>) {
|
func objectMonitor(monitor: ObjectMonitor<MyPersonEntity>, didUpdateObject object: MyPersonEntity, changedPersistentKeys: Set<KeyPathString>) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
|||||||
The list of key path strings to group results with
|
The list of key path strings to group results with
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public var keyPaths: [RawKeyPath] {
|
public var keyPaths: [KeyPathString] {
|
||||||
|
|
||||||
return self.bridgeToSwift.keyPaths
|
return self.bridgeToSwift.keyPaths
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
|||||||
- parameter keyPath: a key path string to group results with
|
- parameter keyPath: a key path string to group results with
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public convenience init(keyPath: RawKeyPath) {
|
public convenience init(keyPath: KeyPathString) {
|
||||||
|
|
||||||
self.init(GroupBy(keyPath))
|
self.init(GroupBy(keyPath))
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
|
|||||||
- parameter keyPaths: a list of key path strings to group results with
|
- parameter keyPaths: a list of key path strings to group results with
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public convenience init(keyPaths: [RawKeyPath]) {
|
public convenience init(keyPaths: [KeyPathString]) {
|
||||||
|
|
||||||
self.init(GroupBy(keyPaths))
|
self.init(GroupBy(keyPaths))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func keyPath(_ sectionKeyPath: RawKeyPath) -> CSSectionBy {
|
public static func keyPath(_ sectionKeyPath: KeyPathString) -> CSSectionBy {
|
||||||
|
|
||||||
return self.init(SectionBy(sectionKeyPath))
|
return self.init(SectionBy(sectionKeyPath))
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
- returns: a `CSSectionBy` clause with the key path to use to group `CSListMonitor` objects into sections
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func keyPath(_ sectionKeyPath: RawKeyPath, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
|
public static func keyPath(_ sectionKeyPath: KeyPathString, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
|
||||||
|
|
||||||
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
|
return self.init(SectionBy(sectionKeyPath, sectionIndexTransformer))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- parameter keyPath: the attribute name
|
- parameter keyPath: the attribute name
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public convenience init(keyPath: RawKeyPath) {
|
public convenience init(keyPath: KeyPathString) {
|
||||||
|
|
||||||
self.init(.attribute(keyPath))
|
self.init(.attribute(keyPath))
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute
|
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the average value of an attribute
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func average(_ keyPath: RawKeyPath, as alias: RawKeyPath?) -> CSSelectTerm {
|
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.average(keyPath, as: alias))
|
return self.init(.average(keyPath, as: alias))
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `SelectTerm` to a `Select` clause for a count query
|
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func count(_ keyPath: RawKeyPath, as alias: RawKeyPath?) -> CSSelectTerm {
|
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.count(keyPath, as: alias))
|
return self.init(.count(keyPath, as: alias))
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute
|
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the maximum value for an attribute
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func maximum(_ keyPath: RawKeyPath, as alias: RawKeyPath?) -> CSSelectTerm {
|
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.maximum(keyPath, as: alias))
|
return self.init(.maximum(keyPath, as: alias))
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute
|
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the minimum value for an attribute
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func minimum(_ keyPath: RawKeyPath, as alias: RawKeyPath?) -> CSSelectTerm {
|
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.minimum(keyPath, as: alias))
|
return self.init(.minimum(keyPath, as: alias))
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute
|
- returns: a `CSSelectTerm` to a `CSSelect` clause for querying the sum value for an attribute
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func sum(_ keyPath: RawKeyPath, as alias: RawKeyPath?) -> CSSelectTerm {
|
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString?) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.sum(keyPath, as: alias))
|
return self.init(.sum(keyPath, as: alias))
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ public final class CSSelectTerm: NSObject, CoreStoreObjectiveCType {
|
|||||||
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public static func objectIDAs(_ alias: RawKeyPath? = nil) -> CSSelectTerm {
|
public static func objectIDAs(_ alias: KeyPathString? = nil) -> CSSelectTerm {
|
||||||
|
|
||||||
return self.init(.objectID(as: alias))
|
return self.init(.objectID(as: alias))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
|||||||
- parameter value: the arguments for the `==` operator
|
- parameter value: the arguments for the `==` operator
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public convenience init(keyPath: RawKeyPath, isEqualTo value: CoreDataNativeType?) {
|
public convenience init(keyPath: KeyPathString, isEqualTo value: CoreDataNativeType?) {
|
||||||
|
|
||||||
self.init(value == nil || value is NSNull
|
self.init(value == nil || value is NSNull
|
||||||
? Where("\(keyPath) == nil")
|
? Where("\(keyPath) == nil")
|
||||||
@@ -99,7 +99,7 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
|
|||||||
- parameter list: the array to check membership of
|
- parameter list: the array to check membership of
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public convenience init(keyPath: RawKeyPath, isMemberOf list: [CoreDataNativeType]) {
|
public convenience init(keyPath: KeyPathString, isMemberOf list: [CoreDataNativeType]) {
|
||||||
|
|
||||||
self.init(Where("\(keyPath) IN %@", list as NSArray))
|
self.init(Where("\(keyPath) IN %@", list as NSArray))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#define CORESTORE_RETURNS_RETAINED __attribute__((ns_returns_retained))
|
#define CORESTORE_RETURNS_RETAINED __attribute__((ns_returns_retained))
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - RawKeyPath Utilities
|
#pragma mark - KeyPathString Utilities
|
||||||
|
|
||||||
#define CSKeyPath(type, property) ({ \
|
#define CSKeyPath(type, property) ({ \
|
||||||
type *_je_keypath_dummy __attribute__((unused)); \
|
type *_je_keypath_dummy __attribute__((unused)); \
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ import CoreData
|
|||||||
private enum Static {
|
private enum Static {
|
||||||
|
|
||||||
static let queue = DispatchQueue.concurrent("com.coreStore.coreStoreManagerObjectBarrierQueue")
|
static let queue = DispatchQueue.concurrent("com.coreStore.coreStoreManagerObjectBarrierQueue")
|
||||||
static var cache: [ObjectIdentifier: [RawKeyPath: Set<RawKeyPath>]] = [:]
|
static var cache: [ObjectIdentifier: [KeyPathString: Set<KeyPathString>]] = [:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
}
|
}
|
||||||
let rawModel = NSManagedObjectModel()
|
let rawModel = NSManagedObjectModel()
|
||||||
var entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription] = [:]
|
var entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription] = [:]
|
||||||
var allCustomGettersSetters: [DynamicEntity: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]] = [:]
|
var allCustomGettersSetters: [DynamicEntity: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]] = [:]
|
||||||
for entity in self.allEntities {
|
for entity in self.allEntities {
|
||||||
|
|
||||||
let (entityDescription, customGetterSetterByKeyPaths) = self.entityDescription(
|
let (entityDescription, customGetterSetterByKeyPaths) = self.entityDescription(
|
||||||
@@ -253,10 +253,10 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
private let allEntities: Set<DynamicEntity>
|
private let allEntities: Set<DynamicEntity>
|
||||||
|
|
||||||
private var entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription] = [:]
|
private var entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription] = [:]
|
||||||
private var customGettersSettersByEntity: [DynamicEntity: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]] = [:]
|
private var customGettersSettersByEntity: [DynamicEntity: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]] = [:]
|
||||||
private weak var cachedRawModel: NSManagedObjectModel?
|
private weak var cachedRawModel: NSManagedObjectModel?
|
||||||
|
|
||||||
private func entityDescription(for entity: DynamicEntity, initializer: (DynamicEntity, ModelVersion) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter])) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]) {
|
private func entityDescription(for entity: DynamicEntity, initializer: (DynamicEntity, ModelVersion) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter])) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]) {
|
||||||
|
|
||||||
if let cachedEntityDescription = self.entityDescriptionsByEntity[entity] {
|
if let cachedEntityDescription = self.entityDescriptionsByEntity[entity] {
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
return (entityDescription, customGetterSetterByKeyPaths)
|
return (entityDescription, customGetterSetterByKeyPaths)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func firstPassCreateEntityDescription(from entity: DynamicEntity, in modelVersion: ModelVersion) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]) {
|
private static func firstPassCreateEntityDescription(from entity: DynamicEntity, in modelVersion: ModelVersion) -> (entity: NSEntityDescription, customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]) {
|
||||||
|
|
||||||
let entityDescription = NSEntityDescription()
|
let entityDescription = NSEntityDescription()
|
||||||
entityDescription.coreStoreEntity = entity
|
entityDescription.coreStoreEntity = entity
|
||||||
@@ -278,8 +278,8 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
entityDescription.versionHashModifier = entity.versionHashModifier
|
entityDescription.versionHashModifier = entity.versionHashModifier
|
||||||
entityDescription.managedObjectClassName = CoreStoreManagedObject.cs_subclassName(for: entity, in: modelVersion)
|
entityDescription.managedObjectClassName = CoreStoreManagedObject.cs_subclassName(for: entity, in: modelVersion)
|
||||||
|
|
||||||
var keyPathsByAffectedKeyPaths: [RawKeyPath: Set<RawKeyPath>] = [:]
|
var keyPathsByAffectedKeyPaths: [KeyPathString: Set<KeyPathString>] = [:]
|
||||||
var customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter] = [:]
|
var customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter] = [:]
|
||||||
func createProperties(for type: CoreStoreObject.Type) -> [NSPropertyDescription] {
|
func createProperties(for type: CoreStoreObject.Type) -> [NSPropertyDescription] {
|
||||||
|
|
||||||
var propertyDescriptions: [NSPropertyDescription] = []
|
var propertyDescriptions: [NSPropertyDescription] = []
|
||||||
@@ -443,9 +443,9 @@ public final class CoreStoreSchema: DynamicSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func fourthPassSynthesizeManagedObjectClasses(for entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription], allCustomGettersSetters: [DynamicEntity: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]]) {
|
private static func fourthPassSynthesizeManagedObjectClasses(for entityDescriptionsByEntity: [DynamicEntity: NSEntityDescription], allCustomGettersSetters: [DynamicEntity: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]]) {
|
||||||
|
|
||||||
func createManagedObjectSubclass(for entityDescription: NSEntityDescription, customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]?) {
|
func createManagedObjectSubclass(for entityDescription: NSEntityDescription, customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]?) {
|
||||||
|
|
||||||
let superEntity = entityDescription.superentity
|
let superEntity = entityDescription.superentity
|
||||||
let className = entityDescription.managedObjectClassName!
|
let className = entityDescription.managedObjectClassName!
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
/**
|
/**
|
||||||
Accesses the property value via its keyPath.
|
Accesses the property value via its keyPath.
|
||||||
*/
|
*/
|
||||||
public subscript(attribute: RawKeyPath) -> Any? {
|
public subscript(attribute: KeyPathString) -> Any? {
|
||||||
|
|
||||||
return self.rawObject.cs_accessValueForKVCKey(attribute)
|
return self.rawObject.cs_accessValueForKVCKey(attribute)
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
/**
|
/**
|
||||||
Accesses or mutates the property value via its keyPath.
|
Accesses or mutates the property value via its keyPath.
|
||||||
*/
|
*/
|
||||||
public subscript(attribute: RawKeyPath) -> Any? {
|
public subscript(attribute: KeyPathString) -> Any? {
|
||||||
|
|
||||||
get { return self.rawObject.cs_accessValueForKVCKey(attribute) }
|
get { return self.rawObject.cs_accessValueForKVCKey(attribute) }
|
||||||
set { self.rawObject.cs_setValue(newValue, forKVCKey: attribute) }
|
set { self.rawObject.cs_setValue(newValue, forKVCKey: attribute) }
|
||||||
@@ -304,7 +304,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
internal init(_ rawObject: NSManagedObject, _ sourceAttributesByDestinationKey: [RawKeyPath: NSAttributeDescription]) {
|
internal init(_ rawObject: NSManagedObject, _ sourceAttributesByDestinationKey: [KeyPathString: NSAttributeDescription]) {
|
||||||
|
|
||||||
self.rawObject = rawObject
|
self.rawObject = rawObject
|
||||||
self.sourceAttributesByDestinationKey = sourceAttributesByDestinationKey
|
self.sourceAttributesByDestinationKey = sourceAttributesByDestinationKey
|
||||||
@@ -314,7 +314,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
// MARK: FilePrivate
|
// MARK: FilePrivate
|
||||||
|
|
||||||
fileprivate let rawObject: NSManagedObject
|
fileprivate let rawObject: NSManagedObject
|
||||||
fileprivate let sourceAttributesByDestinationKey: [RawKeyPath: NSAttributeDescription]
|
fileprivate let sourceAttributesByDestinationKey: [KeyPathString: NSAttributeDescription]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
let transformedRenamingIdentifiers = Set(destinationAttributes.keys)
|
let transformedRenamingIdentifiers = Set(destinationAttributes.keys)
|
||||||
.intersection(sourceAttributes.keys)
|
.intersection(sourceAttributes.keys)
|
||||||
|
|
||||||
var sourceAttributesByDestinationKey: [RawKeyPath: NSAttributeDescription] = [:]
|
var sourceAttributesByDestinationKey: [KeyPathString: NSAttributeDescription] = [:]
|
||||||
for renamingIdentifier in transformedRenamingIdentifiers {
|
for renamingIdentifier in transformedRenamingIdentifiers {
|
||||||
|
|
||||||
let sourceAttribute = sourceAttributes[renamingIdentifier]!.attribute
|
let sourceAttribute = sourceAttributes[renamingIdentifier]!.attribute
|
||||||
@@ -535,7 +535,7 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
|
|
||||||
let userInfo = mapping.userInfo!
|
let userInfo = mapping.userInfo!
|
||||||
let transformer = userInfo[CustomEntityMigrationPolicy.UserInfoKey.transformer]! as! CustomMapping.Transformer
|
let transformer = userInfo[CustomEntityMigrationPolicy.UserInfoKey.transformer]! as! CustomMapping.Transformer
|
||||||
let sourceAttributesByDestinationKey = userInfo[CustomEntityMigrationPolicy.UserInfoKey.sourceAttributesByDestinationKey] as! [RawKeyPath: NSAttributeDescription]
|
let sourceAttributesByDestinationKey = userInfo[CustomEntityMigrationPolicy.UserInfoKey.sourceAttributesByDestinationKey] as! [KeyPathString: NSAttributeDescription]
|
||||||
|
|
||||||
var destinationObject: UnsafeDestinationObject?
|
var destinationObject: UnsafeDestinationObject?
|
||||||
try transformer(
|
try transformer(
|
||||||
@@ -585,8 +585,8 @@ public class CustomSchemaMappingProvider: Hashable, SchemaMappingProvider {
|
|||||||
var insertMappings: Set<CustomMapping> = []
|
var insertMappings: Set<CustomMapping> = []
|
||||||
var copyMappings: Set<CustomMapping> = []
|
var copyMappings: Set<CustomMapping> = []
|
||||||
var transformMappings: Set<CustomMapping> = []
|
var transformMappings: Set<CustomMapping> = []
|
||||||
var allMappedSourceKeys: [RawKeyPath: RawKeyPath] = [:]
|
var allMappedSourceKeys: [KeyPathString: KeyPathString] = [:]
|
||||||
var allMappedDestinationKeys: [RawKeyPath: RawKeyPath] = [:]
|
var allMappedDestinationKeys: [KeyPathString: KeyPathString] = [:]
|
||||||
|
|
||||||
let sourceRenamingIdentifiers = sourceModel.cs_resolvedRenamingIdentities()
|
let sourceRenamingIdentifiers = sourceModel.cs_resolvedRenamingIdentities()
|
||||||
let sourceEntityNames = sourceModel.entitiesByName
|
let sourceEntityNames = sourceModel.entitiesByName
|
||||||
|
|||||||
143
Sources/FetchCondition.swift
Normal file
143
Sources/FetchCondition.swift
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
//
|
||||||
|
// FetchCondition.swift
|
||||||
|
// CoreStore
|
||||||
|
//
|
||||||
|
// Copyright © 2017 John Rommel Estropia
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import CoreData
|
||||||
|
|
||||||
|
public struct ChainedClauseBuilder<T: DynamicObject> {
|
||||||
|
|
||||||
|
public let from: From<T>
|
||||||
|
public let fetchClauses: [FetchClause] = []
|
||||||
|
|
||||||
|
internal init(from: From<T>) {
|
||||||
|
|
||||||
|
self.from = from
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension From: ClauseChain {
|
||||||
|
|
||||||
|
public typealias ObjectType = T
|
||||||
|
public typealias TraitType = FetchTrait
|
||||||
|
|
||||||
|
public var builder: ChainedClauseBuilder<T> {
|
||||||
|
|
||||||
|
return .init(from: self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ChainedWhere<D: DynamicObject, T: ClauseTrait>: ClauseChain {
|
||||||
|
|
||||||
|
public typealias ObjectType = D
|
||||||
|
public typealias TraitType = T
|
||||||
|
|
||||||
|
public let builder: ChainedClauseBuilder<ObjectType>
|
||||||
|
|
||||||
|
fileprivate init(builder: ChainedClauseBuilder<ObjectType>) {
|
||||||
|
|
||||||
|
var newBuilder = builder
|
||||||
|
// newBuilder.fetchClauses.append(Where())
|
||||||
|
self.builder = newBuilder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ChainedOrderBy<D: DynamicObject, T: ClauseTrait>: ClauseChain {
|
||||||
|
|
||||||
|
public typealias ObjectType = D
|
||||||
|
public typealias TraitType = T
|
||||||
|
|
||||||
|
public let builder: ChainedClauseBuilder<ObjectType>
|
||||||
|
|
||||||
|
fileprivate init(builder: ChainedClauseBuilder<ObjectType>) {
|
||||||
|
|
||||||
|
var newBuilder = builder
|
||||||
|
// newBuilder.fetchClauses.append(Where())
|
||||||
|
self.builder = newBuilder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ChainedSelect<D: DynamicObject, T: ClauseTrait>: ClauseChain {
|
||||||
|
|
||||||
|
public typealias ObjectType = D
|
||||||
|
public typealias TraitType = T
|
||||||
|
|
||||||
|
public let builder: ChainedClauseBuilder<ObjectType>
|
||||||
|
|
||||||
|
fileprivate init(builder: ChainedClauseBuilder<ObjectType>) {
|
||||||
|
|
||||||
|
var newBuilder = builder
|
||||||
|
// newBuilder.fetchClauses.append(Where())
|
||||||
|
self.builder = newBuilder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ClauseTrait {}
|
||||||
|
public enum FetchTrait: ClauseTrait {}
|
||||||
|
public enum QueryTrait: ClauseTrait {}
|
||||||
|
public enum SectionTrait: ClauseTrait {}
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ClauseChain {
|
||||||
|
|
||||||
|
associatedtype ObjectType: DynamicObject
|
||||||
|
associatedtype TraitType: ClauseTrait
|
||||||
|
|
||||||
|
var builder: ChainedClauseBuilder<ObjectType> { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension ClauseChain where Self.TraitType == FetchTrait {
|
||||||
|
|
||||||
|
public func `where`() -> ChainedWhere<ObjectType, FetchTrait> {
|
||||||
|
|
||||||
|
return .init(builder: self.builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func orderBy() -> ChainedOrderBy<ObjectType, FetchTrait> {
|
||||||
|
|
||||||
|
return .init(builder: self.builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func select() -> ChainedSelect<ObjectType, QueryTrait> {
|
||||||
|
|
||||||
|
return .init(builder: self.builder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension ClauseChain where Self.TraitType == QueryTrait {
|
||||||
|
|
||||||
|
public func `where`() -> ChainedWhere<ObjectType, QueryTrait> {
|
||||||
|
|
||||||
|
return .init(builder: self.builder)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func orderBy() -> ChainedOrderBy<ObjectType, QueryTrait> {
|
||||||
|
|
||||||
|
return .init(builder: self.builder)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ public struct GroupBy: QueryClause, Hashable {
|
|||||||
/**
|
/**
|
||||||
The list of key path strings to group results with
|
The list of key path strings to group results with
|
||||||
*/
|
*/
|
||||||
public let keyPaths: [RawKeyPath]
|
public let keyPaths: [KeyPathString]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes a `GroupBy` clause with an empty list of key path strings
|
Initializes a `GroupBy` clause with an empty list of key path strings
|
||||||
@@ -53,7 +53,7 @@ public struct GroupBy: QueryClause, Hashable {
|
|||||||
- parameter keyPath: a key path string to group results with
|
- parameter keyPath: a key path string to group results with
|
||||||
- parameter keyPaths: a series of key path strings to group results with
|
- parameter keyPaths: a series of key path strings to group results with
|
||||||
*/
|
*/
|
||||||
public init(_ keyPath: RawKeyPath, _ keyPaths: RawKeyPath...) {
|
public init(_ keyPath: KeyPathString, _ keyPaths: KeyPathString...) {
|
||||||
|
|
||||||
self.init([keyPath] + keyPaths)
|
self.init([keyPath] + keyPaths)
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public struct GroupBy: QueryClause, Hashable {
|
|||||||
|
|
||||||
- parameter keyPaths: a list of key path strings to group results with
|
- parameter keyPaths: a list of key path strings to group results with
|
||||||
*/
|
*/
|
||||||
public init(_ keyPaths: [RawKeyPath]) {
|
public init(_ keyPaths: [KeyPathString]) {
|
||||||
|
|
||||||
self.keyPaths = keyPaths
|
self.keyPaths = keyPaths
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -997,7 +997,7 @@ public final class ListMonitor<D: DynamicObject>: Hashable {
|
|||||||
|
|
||||||
fileprivate var fetchedResultsController: CoreStoreFetchedResultsController
|
fileprivate var fetchedResultsController: CoreStoreFetchedResultsController
|
||||||
fileprivate let taskGroup = DispatchGroup()
|
fileprivate let taskGroup = DispatchGroup()
|
||||||
fileprivate let sectionIndexTransformer: (_ sectionName: RawKeyPath?) -> String?
|
fileprivate let sectionIndexTransformer: (_ sectionName: KeyPathString?) -> String?
|
||||||
|
|
||||||
private let isSectioned: Bool
|
private let isSectioned: Bool
|
||||||
|
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ internal extension NSEntityDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal var keyPathsByAffectedKeyPaths: [RawKeyPath: Set<RawKeyPath>] {
|
internal var keyPathsByAffectedKeyPaths: [KeyPathString: Set<KeyPathString>] {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
if let userInfo = self.userInfo,
|
if let userInfo = self.userInfo,
|
||||||
let value = userInfo[UserInfoKey.CoreStoreManagedObjectKeyPathsByAffectedKeyPaths] {
|
let value = userInfo[UserInfoKey.CoreStoreManagedObjectKeyPathsByAffectedKeyPaths] {
|
||||||
|
|
||||||
return value as! [RawKeyPath: Set<RawKeyPath>]
|
return value as! [KeyPathString: Set<KeyPathString>]
|
||||||
}
|
}
|
||||||
return [:]
|
return [:]
|
||||||
}
|
}
|
||||||
@@ -97,14 +97,14 @@ internal extension NSEntityDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@nonobjc
|
@nonobjc
|
||||||
internal var customGetterSetterByKeyPaths: [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter] {
|
internal var customGetterSetterByKeyPaths: [KeyPathString: CoreStoreManagedObject.CustomGetterSetter] {
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
||||||
if let userInfo = self.userInfo,
|
if let userInfo = self.userInfo,
|
||||||
let value = userInfo[UserInfoKey.CoreStoreManagedObjectCustomGetterSetterByKeyPaths] {
|
let value = userInfo[UserInfoKey.CoreStoreManagedObjectCustomGetterSetterByKeyPaths] {
|
||||||
|
|
||||||
return value as! [RawKeyPath: CoreStoreManagedObject.CustomGetterSetter]
|
return value as! [KeyPathString: CoreStoreManagedObject.CustomGetterSetter]
|
||||||
}
|
}
|
||||||
return [:]
|
return [:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public extension NSManagedObject {
|
|||||||
- returns: the primitive value for the KVC key
|
- returns: the primitive value for the KVC key
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func getValue(forKvcKey kvcKey: RawKeyPath) -> Any? {
|
public func getValue(forKvcKey kvcKey: KeyPathString) -> Any? {
|
||||||
|
|
||||||
self.willAccessValue(forKey: kvcKey)
|
self.willAccessValue(forKey: kvcKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -102,7 +102,7 @@ public extension NSManagedObject {
|
|||||||
- returns: the primitive value transformed by the `didGetValue` closure
|
- returns: the primitive value transformed by the `didGetValue` closure
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func getValue<T>(forKvcKey kvcKey: RawKeyPath, didGetValue: (Any?) throws -> T) rethrows -> T {
|
public func getValue<T>(forKvcKey kvcKey: KeyPathString, didGetValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
self.willAccessValue(forKey: kvcKey)
|
self.willAccessValue(forKey: kvcKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -121,7 +121,7 @@ public extension NSManagedObject {
|
|||||||
- returns: the primitive value transformed by the `didGetValue` closure
|
- returns: the primitive value transformed by the `didGetValue` closure
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func getValue<T>(forKvcKey kvcKey: RawKeyPath, willGetValue: () throws -> Void, didGetValue: (Any?) throws -> T) rethrows -> T {
|
public func getValue<T>(forKvcKey kvcKey: KeyPathString, willGetValue: () throws -> Void, didGetValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
self.willAccessValue(forKey: kvcKey)
|
self.willAccessValue(forKey: kvcKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -139,7 +139,7 @@ public extension NSManagedObject {
|
|||||||
- parameter KVCKey: the KVC key
|
- parameter KVCKey: the KVC key
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func setValue(_ value: Any?, forKvcKey KVCKey: RawKeyPath) {
|
public func setValue(_ value: Any?, forKvcKey KVCKey: KeyPathString) {
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -157,7 +157,7 @@ public extension NSManagedObject {
|
|||||||
- parameter didSetValue: called after executing `setPrimitiveValue(forKey:)`.
|
- parameter didSetValue: called after executing `setPrimitiveValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func setValue(_ value: Any?, forKvcKey KVCKey: RawKeyPath, didSetValue: () -> Void) {
|
public func setValue(_ value: Any?, forKvcKey KVCKey: KeyPathString, didSetValue: () -> Void) {
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -177,7 +177,7 @@ public extension NSManagedObject {
|
|||||||
- parameter didSetValue: called after executing `setPrimitiveValue(forKey:)`.
|
- parameter didSetValue: called after executing `setPrimitiveValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
@nonobjc @inline(__always)
|
@nonobjc @inline(__always)
|
||||||
public func setValue<T>(_ value: T, forKvcKey KVCKey: RawKeyPath, willSetValue: (T) throws -> Any?, didSetValue: (Any?) -> Void = { _ in }) rethrows {
|
public func setValue<T>(_ value: T, forKvcKey KVCKey: KeyPathString, willSetValue: (T) throws -> Any?, didSetValue: (Any?) -> Void = { _ in }) rethrows {
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -212,7 +212,7 @@ public extension NSManagedObject {
|
|||||||
|
|
||||||
@available(*, deprecated, renamed: "getValue(forKvcKey:)")
|
@available(*, deprecated, renamed: "getValue(forKvcKey:)")
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func accessValueForKVCKey(_ KVCKey: RawKeyPath) -> Any? {
|
public func accessValueForKVCKey(_ KVCKey: KeyPathString) -> Any? {
|
||||||
|
|
||||||
self.willAccessValue(forKey: KVCKey)
|
self.willAccessValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -225,7 +225,7 @@ public extension NSManagedObject {
|
|||||||
@available(*, deprecated, renamed: "getValue(forKvcKey:didGetValue:)")
|
@available(*, deprecated, renamed: "getValue(forKvcKey:didGetValue:)")
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func accessValueForKVCKey<T>(_ KVCKey: RawKeyPath, _ didAccessPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
public func accessValueForKVCKey<T>(_ KVCKey: KeyPathString, _ didAccessPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
self.willAccessValue(forKey: KVCKey)
|
self.willAccessValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -237,7 +237,7 @@ public extension NSManagedObject {
|
|||||||
|
|
||||||
@available(*, deprecated, renamed: "setValue(_:forKvcKey:)")
|
@available(*, deprecated, renamed: "setValue(_:forKvcKey:)")
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func setValue(_ value: Any?, forKVCKey KVCKey: RawKeyPath) {
|
public func setValue(_ value: Any?, forKVCKey KVCKey: KeyPathString) {
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
@@ -250,7 +250,7 @@ public extension NSManagedObject {
|
|||||||
@available(*, deprecated, renamed: "setValue(_:forKvcKey:didSetValue:)")
|
@available(*, deprecated, renamed: "setValue(_:forKvcKey:didSetValue:)")
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@nonobjc
|
@nonobjc
|
||||||
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: RawKeyPath, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
public func setValue<T>(_ value: Any?, forKVCKey KVCKey: KeyPathString, _ didSetPrimitiveValue: (Any?) throws -> T) rethrows -> T {
|
||||||
|
|
||||||
self.willChangeValue(forKey: KVCKey)
|
self.willChangeValue(forKey: KVCKey)
|
||||||
defer {
|
defer {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public extension NSManagedObject {
|
|||||||
- returns: the primitive value for the KVC key
|
- returns: the primitive value for the KVC key
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public func cs_accessValueForKVCKey(_ KVCKey: RawKeyPath) -> Any? {
|
public func cs_accessValueForKVCKey(_ KVCKey: KeyPathString) -> Any? {
|
||||||
|
|
||||||
return self.getValue(forKvcKey: KVCKey)
|
return self.getValue(forKvcKey: KVCKey)
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public extension NSManagedObject {
|
|||||||
- parameter KVCKey: the KVC key
|
- parameter KVCKey: the KVC key
|
||||||
*/
|
*/
|
||||||
@objc
|
@objc
|
||||||
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: RawKeyPath) {
|
public func cs_setValue(_ value: Any?, forKVCKey KVCKey: KeyPathString) {
|
||||||
|
|
||||||
self.setValue(value, forKvcKey: KVCKey)
|
self.setValue(value, forKvcKey: KVCKey)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public protocol ObjectObserver: class {
|
|||||||
- parameter object: the `DynamicObject` instance being observed
|
- parameter object: the `DynamicObject` instance being observed
|
||||||
- parameter changedPersistentKeys: a `Set` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
|
- parameter changedPersistentKeys: a `Set` of key paths for the attributes that were changed. Note that `changedPersistentKeys` only contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.
|
||||||
*/
|
*/
|
||||||
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<RawKeyPath>)
|
func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPathString>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handles processing right after `object` is deleted. (Optional)
|
Handles processing right after `object` is deleted. (Optional)
|
||||||
@@ -81,7 +81,7 @@ public extension ObjectObserver {
|
|||||||
|
|
||||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
|
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
|
||||||
|
|
||||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<RawKeyPath>) { }
|
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPathString>) { }
|
||||||
|
|
||||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
|
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import Foundation
|
|||||||
import CoreData
|
import CoreData
|
||||||
|
|
||||||
|
|
||||||
// MARK: - RawKeyPath
|
// MARK: - KeyPathString
|
||||||
|
|
||||||
public typealias RawKeyPath = String
|
public typealias KeyPathString = String
|
||||||
|
|
||||||
|
|
||||||
// MARK: - SortKey
|
// MARK: - SortKey
|
||||||
@@ -40,14 +40,14 @@ public typealias RawKeyPath = String
|
|||||||
public enum SortKey {
|
public enum SortKey {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicates that the `RawKeyPath` should be sorted in ascending order
|
Indicates that the `KeyPathString` should be sorted in ascending order
|
||||||
*/
|
*/
|
||||||
case ascending(RawKeyPath)
|
case ascending(KeyPathString)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicates that the `RawKeyPath` should be sorted in descending order
|
Indicates that the `KeyPathString` should be sorted in descending order
|
||||||
*/
|
*/
|
||||||
case descending(RawKeyPath)
|
case descending(KeyPathString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
versionHashModifier: String? = nil,
|
versionHashModifier: String? = nil,
|
||||||
renamingIdentifier: String? = nil,
|
renamingIdentifier: String? = nil,
|
||||||
@@ -129,7 +129,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
versionHashModifier: String? = nil,
|
versionHashModifier: String? = nil,
|
||||||
@@ -164,7 +164,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
versionHashModifier: String? = nil,
|
versionHashModifier: String? = nil,
|
||||||
@@ -199,7 +199,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
versionHashModifier: String? = nil,
|
versionHashModifier: String? = nil,
|
||||||
@@ -234,14 +234,14 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
// MARK: RelationshipProtocol
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isToMany = false
|
internal let isToMany = false
|
||||||
internal let isOrdered = false
|
internal let isOrdered = false
|
||||||
internal let deleteRule: NSDeleteRule
|
internal let deleteRule: NSDeleteRule
|
||||||
internal let minCount: Int = 0
|
internal let minCount: Int = 0
|
||||||
internal let maxCount: Int = 1
|
internal let maxCount: Int = 1
|
||||||
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> RawKeyPath?)
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?)
|
||||||
internal let versionHashModifier: String?
|
internal let versionHashModifier: String?
|
||||||
internal let renamingIdentifier: String?
|
internal let renamingIdentifier: String?
|
||||||
internal let affectedByKeyPaths: () -> Set<String>
|
internal let affectedByKeyPaths: () -> Set<String>
|
||||||
@@ -294,7 +294,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private init(keyPath: RawKeyPath, inverseKeyPath: @escaping () -> RawKeyPath?, deleteRule: DeleteRule, versionHashModifier: String?, renamingIdentifier: String?, affectedByKeyPaths: @autoclosure @escaping () -> Set<String>) {
|
private init(keyPath: KeyPathString, inverseKeyPath: @escaping () -> KeyPathString?, deleteRule: DeleteRule, versionHashModifier: String?, renamingIdentifier: String?, affectedByKeyPaths: @autoclosure @escaping () -> Set<String>) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.keyPath = keyPath
|
||||||
self.deleteRule = deleteRule.nativeValue
|
self.deleteRule = deleteRule.nativeValue
|
||||||
@@ -341,7 +341,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
maxCount: Int = 0,
|
maxCount: Int = 0,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
@@ -381,7 +381,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
maxCount: Int = 0,
|
maxCount: Int = 0,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
||||||
@@ -422,7 +422,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
maxCount: Int = 0,
|
maxCount: Int = 0,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
||||||
@@ -463,7 +463,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
maxCount: Int = 0,
|
maxCount: Int = 0,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
||||||
@@ -502,7 +502,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
// MARK: RelationshipProtocol
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isToMany = true
|
internal let isToMany = true
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
@@ -510,7 +510,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
internal let deleteRule: NSDeleteRule
|
internal let deleteRule: NSDeleteRule
|
||||||
internal let minCount: Int
|
internal let minCount: Int
|
||||||
internal let maxCount: Int
|
internal let maxCount: Int
|
||||||
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> RawKeyPath?)
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?)
|
||||||
internal let versionHashModifier: String?
|
internal let versionHashModifier: String?
|
||||||
internal let renamingIdentifier: String?
|
internal let renamingIdentifier: String?
|
||||||
internal let affectedByKeyPaths: () -> Set<String>
|
internal let affectedByKeyPaths: () -> Set<String>
|
||||||
@@ -615,7 +615,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
maxCount: Int = 0,
|
maxCount: Int = 0,
|
||||||
@@ -655,7 +655,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
@@ -696,7 +696,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
@@ -737,7 +737,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
|
||||||
deleteRule: DeleteRule = .nullify,
|
deleteRule: DeleteRule = .nullify,
|
||||||
minCount: Int = 0,
|
minCount: Int = 0,
|
||||||
@@ -776,7 +776,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
// MARK: RelationshipProtocol
|
// MARK: RelationshipProtocol
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isToMany = true
|
internal let isToMany = true
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
@@ -784,7 +784,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
internal let deleteRule: NSDeleteRule
|
internal let deleteRule: NSDeleteRule
|
||||||
internal let minCount: Int
|
internal let minCount: Int
|
||||||
internal let maxCount: Int
|
internal let maxCount: Int
|
||||||
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> RawKeyPath?)
|
internal let inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?)
|
||||||
internal let versionHashModifier: String?
|
internal let versionHashModifier: String?
|
||||||
internal let renamingIdentifier: String?
|
internal let renamingIdentifier: String?
|
||||||
internal let affectedByKeyPaths: () -> Set<String>
|
internal let affectedByKeyPaths: () -> Set<String>
|
||||||
@@ -837,7 +837,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
|
|||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
private init(keyPath: RawKeyPath, inverseKeyPath: @escaping () -> RawKeyPath?, deleteRule: DeleteRule, minCount: Int, maxCount: Int, versionHashModifier: String?, renamingIdentifier: String?, affectedByKeyPaths: @autoclosure @escaping () -> Set<String>) {
|
private init(keyPath: KeyPathString, inverseKeyPath: @escaping () -> KeyPathString?, deleteRule: DeleteRule, minCount: Int, maxCount: Int, versionHashModifier: String?, renamingIdentifier: String?, affectedByKeyPaths: @autoclosure @escaping () -> Set<String>) {
|
||||||
|
|
||||||
self.keyPath = keyPath
|
self.keyPath = keyPath
|
||||||
self.deleteRule = deleteRule.nativeValue
|
self.deleteRule = deleteRule.nativeValue
|
||||||
@@ -1210,11 +1210,11 @@ extension RelationshipContainer.ToManyUnordered {
|
|||||||
|
|
||||||
internal protocol RelationshipProtocol: class {
|
internal protocol RelationshipProtocol: class {
|
||||||
|
|
||||||
var keyPath: RawKeyPath { get }
|
var keyPath: KeyPathString { get }
|
||||||
var isToMany: Bool { get }
|
var isToMany: Bool { get }
|
||||||
var isOrdered: Bool { get }
|
var isOrdered: Bool { get }
|
||||||
var deleteRule: NSDeleteRule { get }
|
var deleteRule: NSDeleteRule { get }
|
||||||
var inverse: (type: CoreStoreObject.Type, keyPath: () -> RawKeyPath?) { get }
|
var inverse: (type: CoreStoreObject.Type, keyPath: () -> KeyPathString?) { get }
|
||||||
var affectedByKeyPaths: () -> Set<String> { get }
|
var affectedByKeyPaths: () -> Set<String> { get }
|
||||||
weak var parentObject: CoreStoreObject? { get set }
|
weak var parentObject: CoreStoreObject? { get set }
|
||||||
var versionHashModifier: String? { get }
|
var versionHashModifier: String? { get }
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public struct SectionBy {
|
|||||||
|
|
||||||
- parameter sectionKeyPath: the key path to use to group the objects into sections
|
- parameter sectionKeyPath: the key path to use to group the objects into sections
|
||||||
*/
|
*/
|
||||||
public init(_ sectionKeyPath: RawKeyPath) {
|
public init(_ sectionKeyPath: KeyPathString) {
|
||||||
|
|
||||||
self.init(sectionKeyPath, { $0 })
|
self.init(sectionKeyPath, { $0 })
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ public struct SectionBy {
|
|||||||
- parameter sectionKeyPath: the key path to use to group the objects into sections
|
- 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
|
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section name
|
||||||
*/
|
*/
|
||||||
public init(_ sectionKeyPath: RawKeyPath, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
|
public init(_ sectionKeyPath: KeyPathString, _ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) {
|
||||||
|
|
||||||
self.sectionKeyPath = sectionKeyPath
|
self.sectionKeyPath = sectionKeyPath
|
||||||
self.sectionIndexTransformer = sectionIndexTransformer
|
self.sectionIndexTransformer = sectionIndexTransformer
|
||||||
@@ -68,6 +68,6 @@ public struct SectionBy {
|
|||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
internal let sectionKeyPath: RawKeyPath
|
internal let sectionKeyPath: KeyPathString
|
||||||
internal let sectionIndexTransformer: (_ sectionName: String?) -> String?
|
internal let sectionIndexTransformer: (_ sectionName: String?) -> String?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter keyPath: the attribute name
|
- parameter keyPath: the attribute name
|
||||||
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
- returns: a `SelectTerm` to a `Select` clause for querying an entity attribute
|
||||||
*/
|
*/
|
||||||
public static func attribute(_ keyPath: RawKeyPath) -> SelectTerm {
|
public static func attribute(_ keyPath: KeyPathString) -> SelectTerm {
|
||||||
|
|
||||||
return ._attribute(keyPath)
|
return ._attribute(keyPath)
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "average(<attributeName>)" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for querying the average value of an attribute
|
||||||
*/
|
*/
|
||||||
public static func average(_ keyPath: RawKeyPath, as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._aggregate(
|
return ._aggregate(
|
||||||
function: "average:",
|
function: "average:",
|
||||||
@@ -113,7 +113,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "count(<attributeName>)" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for a count query
|
||||||
*/
|
*/
|
||||||
public static func count(_ keyPath: RawKeyPath, as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._aggregate(
|
return ._aggregate(
|
||||||
function: "count:",
|
function: "count:",
|
||||||
@@ -135,7 +135,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "max(<attributeName>)" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for querying the maximum value for an attribute
|
||||||
*/
|
*/
|
||||||
public static func maximum(_ keyPath: RawKeyPath, as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._aggregate(
|
return ._aggregate(
|
||||||
function: "max:",
|
function: "max:",
|
||||||
@@ -157,7 +157,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "min(<attributeName>)" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for querying the minimum value for an attribute
|
||||||
*/
|
*/
|
||||||
public static func minimum(_ keyPath: RawKeyPath, as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._aggregate(
|
return ._aggregate(
|
||||||
function: "min:",
|
function: "min:",
|
||||||
@@ -179,7 +179,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "sum(<attributeName>)" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||||
*/
|
*/
|
||||||
public static func sum(_ keyPath: RawKeyPath, as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._aggregate(
|
return ._aggregate(
|
||||||
function: "sum:",
|
function: "sum:",
|
||||||
@@ -202,7 +202,7 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
- parameter alias: the dictionary key to use to access the result. Ignored when the query return value is not an `NSDictionary`. If `nil`, the default key "objecID" is used
|
- 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
|
- returns: a `SelectTerm` to a `Select` clause for querying the sum value for an attribute
|
||||||
*/
|
*/
|
||||||
public static func objectID(as alias: RawKeyPath? = nil) -> SelectTerm {
|
public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm {
|
||||||
|
|
||||||
return ._identity(
|
return ._identity(
|
||||||
alias: alias ?? "objectID",
|
alias: alias ?? "objectID",
|
||||||
@@ -213,17 +213,17 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
|
|
||||||
// MARK: ExpressibleByStringLiteral
|
// MARK: ExpressibleByStringLiteral
|
||||||
|
|
||||||
public init(stringLiteral value: RawKeyPath) {
|
public init(stringLiteral value: KeyPathString) {
|
||||||
|
|
||||||
self = ._attribute(value)
|
self = ._attribute(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(unicodeScalarLiteral value: RawKeyPath) {
|
public init(unicodeScalarLiteral value: KeyPathString) {
|
||||||
|
|
||||||
self = ._attribute(value)
|
self = ._attribute(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(extendedGraphemeClusterLiteral value: RawKeyPath) {
|
public init(extendedGraphemeClusterLiteral value: KeyPathString) {
|
||||||
|
|
||||||
self = ._attribute(value)
|
self = ._attribute(value)
|
||||||
}
|
}
|
||||||
@@ -274,8 +274,8 @@ public enum SelectTerm: ExpressibleByStringLiteral, Hashable {
|
|||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
case _attribute(RawKeyPath)
|
case _attribute(KeyPathString)
|
||||||
case _aggregate(function: String, keyPath: RawKeyPath, alias: String, nativeType: NSAttributeType)
|
case _aggregate(function: String, keyPath: KeyPathString, alias: String, nativeType: NSAttributeType)
|
||||||
case _identity(alias: String, nativeType: NSAttributeType)
|
case _identity(alias: String, nativeType: NSAttributeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ internal extension Collection where Iterator.Element == SelectTerm {
|
|||||||
fetchRequest.propertiesToFetch = propertiesToFetch
|
fetchRequest.propertiesToFetch = propertiesToFetch
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func keyPathForFirstSelectTerm() -> RawKeyPath {
|
internal func keyPathForFirstSelectTerm() -> KeyPathString {
|
||||||
|
|
||||||
switch self.first! {
|
switch self.first! {
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
`default`: @autoclosure @escaping () -> V,
|
`default`: @autoclosure @escaping () -> V,
|
||||||
isIndexed: Bool = false,
|
isIndexed: Bool = false,
|
||||||
isTransient: Bool = false,
|
isTransient: Bool = false,
|
||||||
@@ -207,7 +207,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
|||||||
return V.cs_rawAttributeType
|
return V.cs_rawAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isOptional = false
|
internal let isOptional = false
|
||||||
internal let isIndexed: Bool
|
internal let isIndexed: Bool
|
||||||
@@ -323,7 +323,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
`default`: @autoclosure @escaping () -> V? = nil,
|
`default`: @autoclosure @escaping () -> V? = nil,
|
||||||
isIndexed: Bool = false,
|
isIndexed: Bool = false,
|
||||||
isTransient: Bool = false,
|
isTransient: Bool = false,
|
||||||
@@ -405,7 +405,7 @@ public enum ValueContainer<O: CoreStoreObject> {
|
|||||||
return V.cs_rawAttributeType
|
return V.cs_rawAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
internal let isIndexed: Bool
|
internal let isIndexed: Bool
|
||||||
internal let isTransient: Bool
|
internal let isTransient: Bool
|
||||||
@@ -485,7 +485,7 @@ public extension ValueContainer.Required where V: EmptyableAttributeType {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public convenience init(
|
public convenience init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
isIndexed: Bool = false,
|
isIndexed: Bool = false,
|
||||||
isTransient: Bool = false,
|
isTransient: Bool = false,
|
||||||
versionHashModifier: String? = nil,
|
versionHashModifier: String? = nil,
|
||||||
@@ -579,7 +579,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
`default`: @autoclosure @escaping () -> V,
|
`default`: @autoclosure @escaping () -> V,
|
||||||
isIndexed: Bool = false,
|
isIndexed: Bool = false,
|
||||||
isTransient: Bool = false,
|
isTransient: Bool = false,
|
||||||
@@ -660,7 +660,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
return .transformableAttributeType
|
return .transformableAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isOptional = false
|
internal let isOptional = false
|
||||||
internal let isIndexed: Bool
|
internal let isIndexed: Bool
|
||||||
@@ -774,7 +774,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
- parameter affectedByKeyPaths: a set of key paths for properties whose values affect the value of the receiver. This is similar to `NSManagedObject.keyPathsForValuesAffectingValue(forKey:)`.
|
||||||
*/
|
*/
|
||||||
public init(
|
public init(
|
||||||
_ keyPath: RawKeyPath,
|
_ keyPath: KeyPathString,
|
||||||
`default`: @autoclosure @escaping () -> V? = nil,
|
`default`: @autoclosure @escaping () -> V? = nil,
|
||||||
isIndexed: Bool = false,
|
isIndexed: Bool = false,
|
||||||
isTransient: Bool = false,
|
isTransient: Bool = false,
|
||||||
@@ -855,7 +855,7 @@ public enum TransformableContainer<O: CoreStoreObject> {
|
|||||||
return .transformableAttributeType
|
return .transformableAttributeType
|
||||||
}
|
}
|
||||||
|
|
||||||
public let keyPath: RawKeyPath
|
public let keyPath: KeyPathString
|
||||||
|
|
||||||
internal let isOptional = true
|
internal let isOptional = true
|
||||||
internal let isIndexed: Bool
|
internal let isIndexed: Bool
|
||||||
@@ -1211,7 +1211,7 @@ internal protocol AttributeProtocol: class {
|
|||||||
|
|
||||||
static var attributeType: NSAttributeType { get }
|
static var attributeType: NSAttributeType { get }
|
||||||
|
|
||||||
var keyPath: RawKeyPath { get }
|
var keyPath: KeyPathString { get }
|
||||||
var isOptional: Bool { get }
|
var isOptional: Bool { get }
|
||||||
var isIndexed: Bool { get }
|
var isIndexed: Bool { get }
|
||||||
var isTransient: Bool { get }
|
var isTransient: Bool { get }
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter value: the arguments for the `==` operator
|
- parameter value: the arguments for the `==` operator
|
||||||
*/
|
*/
|
||||||
public init(_ keyPath: RawKeyPath, isEqualTo value: Void?) {
|
public init(_ keyPath: KeyPathString, isEqualTo value: Void?) {
|
||||||
|
|
||||||
self.init(NSPredicate(format: "\(keyPath) == nil"))
|
self.init(NSPredicate(format: "\(keyPath) == nil"))
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter value: the arguments for the `==` operator
|
- parameter value: the arguments for the `==` operator
|
||||||
*/
|
*/
|
||||||
public init<T: QueryableAttributeType>(_ keyPath: RawKeyPath, isEqualTo value: T?) {
|
public init<T: QueryableAttributeType>(_ keyPath: KeyPathString, isEqualTo value: T?) {
|
||||||
|
|
||||||
switch value {
|
switch value {
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter object: the arguments for the `==` operator
|
- parameter object: the arguments for the `==` operator
|
||||||
*/
|
*/
|
||||||
public init<T: DynamicObject>(_ keyPath: RawKeyPath, isEqualTo object: T?) {
|
public init<T: DynamicObject>(_ keyPath: KeyPathString, isEqualTo object: T?) {
|
||||||
|
|
||||||
switch object {
|
switch object {
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter list: the sequence to check membership of
|
- parameter list: the sequence to check membership of
|
||||||
*/
|
*/
|
||||||
public init<S: Sequence>(_ keyPath: RawKeyPath, isMemberOf list: S) where S.Iterator.Element: QueryableAttributeType {
|
public init<S: Sequence>(_ keyPath: KeyPathString, isMemberOf list: S) where S.Iterator.Element: QueryableAttributeType {
|
||||||
|
|
||||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_toQueryableNativeType() }) as NSArray))
|
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_toQueryableNativeType() }) as NSArray))
|
||||||
}
|
}
|
||||||
@@ -237,7 +237,7 @@ public struct Where: FetchClause, QueryClause, DeleteClause, Hashable {
|
|||||||
- parameter keyPath: the keyPath to compare with
|
- parameter keyPath: the keyPath to compare with
|
||||||
- parameter list: the sequence to check membership of
|
- parameter list: the sequence to check membership of
|
||||||
*/
|
*/
|
||||||
public init<S: Sequence>(_ keyPath: RawKeyPath, isMemberOf list: S) where S.Iterator.Element: DynamicObject {
|
public init<S: Sequence>(_ keyPath: KeyPathString, isMemberOf list: S) where S.Iterator.Element: DynamicObject {
|
||||||
|
|
||||||
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_id() }) as NSArray))
|
self.init(NSPredicate(format: "\(keyPath) IN %@", list.map({ $0.cs_id() }) as NSArray))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user