From 474f52ed2b3217954067d351561d6360d637a884 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Fri, 22 Sep 2017 00:30:02 +0900 Subject: [PATCH] alow nil comparison for relationship keypaths --- Sources/KeyPath+Querying.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/KeyPath+Querying.swift b/Sources/KeyPath+Querying.swift index 9893789..25b549c 100644 --- a/Sources/KeyPath+Querying.swift +++ b/Sources/KeyPath+Querying.swift @@ -325,6 +325,11 @@ public func == (_ keyPath: KeyPath.ToOne>, return Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) } +public func == (_ keyPath: KeyPath.ToOne>, _ null: Void?) -> Where { + + return Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: nil) +} + public func != (_ keyPath: KeyPath.ToOne>, _ object: D) -> Where { return !Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) @@ -335,6 +340,11 @@ public func != (_ keyPath: KeyPath.ToOne>, return !Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) } +public func != (_ keyPath: KeyPath.ToOne>, _ null: Void?) -> Where { + + return !Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: nil) +} + public func ~= (_ sequence: S, _ keyPath: KeyPath.ToOne>) -> Where where S.Iterator.Element == D { return Where(O.meta[keyPath: keyPath].keyPath, isMemberOf: sequence)