add query overloads to == so comparison with nil don't confuse the compiler

This commit is contained in:
John Estropia
2017-11-09 19:27:56 +09:00
parent 8a4d1cd7c6
commit b2ff8a15ef
2 changed files with 190 additions and 14 deletions

View File

@@ -158,9 +158,9 @@ public struct Where<D: DynamicObject>: WhereClauseType, FetchClause, QueryClause
Initializes a `Where` clause that compares equality to `nil`
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
- parameter null: the arguments for the `==` operator
*/
public init(_ keyPath: KeyPathString, isEqualTo value: Void?) {
public init(_ keyPath: KeyPathString, isEqualTo null: Void?) {
self.init(NSPredicate(format: "\(keyPath) == nil"))
}
@@ -303,22 +303,22 @@ public extension Where where D: NSManagedObject {
Initializes a `Where` clause that compares equality to `nil`
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
- parameter null: the arguments for the `==` operator
*/
public init<V: QueryableAttributeType>(_ keyPath: KeyPath<D, V>, isEqualTo value: Void?) {
public init<V: QueryableAttributeType>(_ keyPath: KeyPath<D, V>, isEqualTo null: Void?) {
self.init(keyPath._kvcKeyPathString!, isEqualTo: value)
self.init(keyPath._kvcKeyPathString!, isEqualTo: null)
}
/**
Initializes a `Where` clause that compares equality to `nil`
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
- parameter null: the arguments for the `==` operator
*/
public init<O: DynamicObject>(_ keyPath: KeyPath<D, O>, isEqualTo value: Void?) {
public init<O: DynamicObject>(_ keyPath: KeyPath<D, O>, isEqualTo null: Void?) {
self.init(keyPath._kvcKeyPathString!, isEqualTo: value)
self.init(keyPath._kvcKeyPathString!, isEqualTo: null)
}
/**
@@ -397,22 +397,22 @@ public extension Where where D: CoreStoreObject {
Initializes a `Where` clause that compares equality to `nil`
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
- parameter null: the arguments for the `==` operator
*/
public init<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, isEqualTo value: Void?) {
public init<V>(_ keyPath: KeyPath<D, ValueContainer<D>.Optional<V>>, isEqualTo null: Void?) {
self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: value)
self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: null)
}
/**
Initializes a `Where` clause that compares equality to `nil`
- parameter keyPath: the keyPath to compare with
- parameter value: the arguments for the `==` operator
- parameter null: the arguments for the `==` operator
*/
public init<O>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isEqualTo value: Void?) {
public init<O>(_ keyPath: KeyPath<D, RelationshipContainer<D>.ToOne<O>>, isEqualTo null: Void?) {
self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: value)
self.init(D.meta[keyPath: keyPath].keyPath, isEqualTo: null)
}
/**