WIP: Query builders

This commit is contained in:
John Rommel Estropia
2017-07-05 08:45:10 +09:00
parent 32743b3aee
commit aff966aac9
25 changed files with 269 additions and 116 deletions

View File

@@ -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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
deleteRule: DeleteRule = .nullify,
versionHashModifier: 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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
deleteRule: DeleteRule = .nullify,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
deleteRule: DeleteRule = .nullify,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
deleteRule: DeleteRule = .nullify,
versionHashModifier: String? = nil,
@@ -234,14 +234,14 @@ public enum RelationshipContainer<O: CoreStoreObject> {
// MARK: RelationshipProtocol
public let keyPath: RawKeyPath
public let keyPath: KeyPathString
internal let isToMany = false
internal let isOrdered = false
internal let deleteRule: NSDeleteRule
internal let minCount: Int = 0
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 renamingIdentifier: String?
internal let affectedByKeyPaths: () -> Set<String>
@@ -294,7 +294,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
// 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.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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
minCount: Int = 0,
maxCount: Int = 0,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
minCount: Int = 0,
maxCount: Int = 0,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
minCount: Int = 0,
maxCount: Int = 0,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
minCount: Int = 0,
maxCount: Int = 0,
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
@@ -502,7 +502,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
// MARK: RelationshipProtocol
public let keyPath: RawKeyPath
public let keyPath: KeyPathString
internal let isToMany = true
internal let isOptional = true
@@ -510,7 +510,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
internal let deleteRule: NSDeleteRule
internal let minCount: 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 renamingIdentifier: 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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
deleteRule: DeleteRule = .nullify,
minCount: 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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToOne<O>,
deleteRule: DeleteRule = .nullify,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyOrdered<O>,
deleteRule: DeleteRule = .nullify,
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:)`.
*/
public convenience init(
_ keyPath: RawKeyPath,
_ keyPath: KeyPathString,
inverse: @escaping (D) -> RelationshipContainer<D>.ToManyUnordered<O>,
deleteRule: DeleteRule = .nullify,
minCount: Int = 0,
@@ -776,7 +776,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
// MARK: RelationshipProtocol
public let keyPath: RawKeyPath
public let keyPath: KeyPathString
internal let isToMany = true
internal let isOptional = true
@@ -784,7 +784,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
internal let deleteRule: NSDeleteRule
internal let minCount: 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 renamingIdentifier: String?
internal let affectedByKeyPaths: () -> Set<String>
@@ -837,7 +837,7 @@ public enum RelationshipContainer<O: CoreStoreObject> {
// 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.deleteRule = deleteRule.nativeValue
@@ -1210,11 +1210,11 @@ extension RelationshipContainer.ToManyUnordered {
internal protocol RelationshipProtocol: class {
var keyPath: RawKeyPath { get }
var keyPath: KeyPathString { get }
var isToMany: Bool { get }
var isOrdered: Bool { 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 }
weak var parentObject: CoreStoreObject? { get set }
var versionHashModifier: String? { get }