From 547fa20f993e0388ab9e89a8d0976ef28146ccd5 Mon Sep 17 00:00:00 2001 From: Nathan Kellert Date: Fri, 26 Jul 2019 19:15:57 -0500 Subject: [PATCH 1/3] Fixing LiveQuery Parse Server error for empty where property. --- Sources/ParseLiveQuery/Internal/QueryEncoder.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/ParseLiveQuery/Internal/QueryEncoder.swift b/Sources/ParseLiveQuery/Internal/QueryEncoder.swift index 885eb8fd..df2da4da 100644 --- a/Sources/ParseLiveQuery/Internal/QueryEncoder.swift +++ b/Sources/ParseLiveQuery/Internal/QueryEncoder.swift @@ -22,7 +22,7 @@ extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject { } if let conditions: [String:AnyObject] = queryState?.value(forKey: "conditions") as? [String:AnyObject] { self["where"] = conditions.encodedQueryDictionary as? Value - } + } else { self["where"] = [:] as? Value } } } @@ -30,7 +30,7 @@ extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject { var encodedQueryDictionary: Dictionary { var encodedQueryDictionary = Dictionary() for (key, val) in self { - if let array = val as? [PFQuery] { + if let array = val as? [PFQuery] { var queries:[Value] = [] for query in array { let queryState = query.value(forKey: "state") as AnyObject? @@ -39,8 +39,7 @@ extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject { } } encodedQueryDictionary[key] = queries as? Value - } - else if let dict = val as? [String:AnyObject] { + } else if let dict = val as? [String:AnyObject] { encodedQueryDictionary[key] = dict.encodedQueryDictionary as? Value } else if let geoPoint = val as? PFGeoPoint { encodedQueryDictionary[key] = geoPoint.encodedDictionary as? Value From 9d9fa1096f929598606ceb1fb7b03205092f8cae Mon Sep 17 00:00:00 2001 From: Nathan Kellert Date: Fri, 26 Jul 2019 19:50:30 -0500 Subject: [PATCH 2/3] Editing Changelog --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f01c3103..f669e89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,10 @@ [Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.5.0...2.6.0) -- Added `@objc` to compile with objective-c. Thanks to [Junya Yamaguchi](https://github.com/junya100) [(#184)](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/184) -- Encode Date object with `__type: Date`. Thanks to [anafang](https://github.com/ananfang) [#186](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/186) +- Fixed issue where no "where" property sent when no constraints where added to a query. This is required by the LiveQuery protocol. +- Support for .or queries. Fixes #156, #47, and #85. Allows orQuery to be encoded without throwing. Thanks to [dblythy](https://github.com/dblythy) +- Added @objc to compile with objective-c . Thanks to [Junya Yamaguchi](https://github.com/junya100) [(#184)](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/184) +- Encode Date object with __type: Date. Thanks to [anafang](https://github.com/ananfang) [#186](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/186) ### 2.5.0 From ea5bf7e32ad0108e3b6295cca8327590c3c82cc7 Mon Sep 17 00:00:00 2001 From: Nathan Kellert Date: Fri, 26 Jul 2019 20:35:21 -0500 Subject: [PATCH 3/3] Fixed formatting. Remove redundant type declaration. --- Sources/ParseLiveQuery/Internal/QueryEncoder.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/ParseLiveQuery/Internal/QueryEncoder.swift b/Sources/ParseLiveQuery/Internal/QueryEncoder.swift index df2da4da..a59c7b14 100644 --- a/Sources/ParseLiveQuery/Internal/QueryEncoder.swift +++ b/Sources/ParseLiveQuery/Internal/QueryEncoder.swift @@ -20,9 +20,11 @@ extension Dictionary where Key: ExpressibleByStringLiteral, Value: AnyObject { if let className = queryState?.value(forKey: "parseClassName") { self["className"] = className as? Value } - if let conditions: [String:AnyObject] = queryState?.value(forKey: "conditions") as? [String:AnyObject] { + if let conditions = queryState?.value(forKey: "conditions") as? [String:AnyObject] { self["where"] = conditions.encodedQueryDictionary as? Value - } else { self["where"] = [:] as? Value } + } else { + self["where"] = [:] as? Value + } } }