From 16225fc4c670deacac5307331ae96bd7fa4a5af9 Mon Sep 17 00:00:00 2001 From: John Rommel Estropia Date: Fri, 22 Sep 2017 00:20:55 +0900 Subject: [PATCH] allow optionals in 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 e06d9e4..9893789 100644 --- a/Sources/KeyPath+Querying.swift +++ b/Sources/KeyPath+Querying.swift @@ -320,11 +320,21 @@ public func == (_ keyPath: KeyPath.ToOne>, return Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) } +public func == (_ keyPath: KeyPath.ToOne>, _ object: D?) -> Where { + + return Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) +} + public func != (_ keyPath: KeyPath.ToOne>, _ object: D) -> Where { return !Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) } +public func != (_ keyPath: KeyPath.ToOne>, _ object: D?) -> Where { + + return !Where(O.meta[keyPath: keyPath].keyPath, isEqualTo: object) +} + public func ~= (_ sequence: S, _ keyPath: KeyPath.ToOne>) -> Where where S.Iterator.Element == D { return Where(O.meta[keyPath: keyPath].keyPath, isMemberOf: sequence)