From fc516a6e48c1c150a0ecac94910bc8dcedfc2e71 Mon Sep 17 00:00:00 2001 From: Corey Date: Mon, 18 Sep 2023 14:52:41 -0400 Subject: [PATCH] fix: includeKeys when fetching pointer (#133) * fix: includeKeys when fetching pointer * lint * add change log entry * fix unwrap for older Swift --------- Co-authored-by: project-academy <32362133+project-academy@users.noreply.github.com> --- CHANGELOG.md | 8 +++++++- .../API/API+NonParseBodyCommand.swift | 2 +- Sources/ParseSwift/Coding/ParseCoding.swift | 2 +- Sources/ParseSwift/ParseConstants.swift | 2 +- Sources/ParseSwift/Types/Pointer.swift | 19 ++++++++++++++----- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf1ddf05..46072ae92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,15 @@ # Parse-Swift Changelog ### main -[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.8.0...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift) +[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.8.1...main), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/main/documentation/parseswift) * _Contributing to this repo? Add info about your change here to be included in the next release_ +### 5.8.1 +[Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.8.0...5.8.1), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.8.1/documentation/parseswift) + +__Fixes__ +* There was an issue where Parse pointers were not sending includeKeys to the server ([#133](https://github.com/netreconlab/Parse-Swift/pull/133)), thanks to [proj-sashido](https://github.com/proj-sashido). + ### 5.8.0 [Full Changelog](https://github.com/netreconlab/Parse-Swift/compare/5.7.4...5.8.0), [Documentation](https://swiftpackageindex.com/netreconlab/Parse-Swift/5.8.0/documentation/parseswift) diff --git a/Sources/ParseSwift/API/API+NonParseBodyCommand.swift b/Sources/ParseSwift/API/API+NonParseBodyCommand.swift index 5c932b03b..8a87cb378 100644 --- a/Sources/ParseSwift/API/API+NonParseBodyCommand.swift +++ b/Sources/ParseSwift/API/API+NonParseBodyCommand.swift @@ -74,7 +74,7 @@ internal extension API { guard var components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return .failure(ParseError(code: .otherCause, - message: "Could not unrwrap url components for \(url)")) + message: "Could not unwrap url components for \(url)")) } components.queryItems = params diff --git a/Sources/ParseSwift/Coding/ParseCoding.swift b/Sources/ParseSwift/Coding/ParseCoding.swift index 9591c1cfa..06b5334dc 100644 --- a/Sources/ParseSwift/Coding/ParseCoding.swift +++ b/Sources/ParseSwift/Coding/ParseCoding.swift @@ -53,7 +53,7 @@ public extension ParseObject { } /// The Parse encoder is used to JSON encode all `ParseObject`s and - /// types in a way meaninful for a Parse Server to consume. + /// types in a way meaningful for a Parse Server to consume. func getEncoder() -> ParseEncoder { return Self.getEncoder() } diff --git a/Sources/ParseSwift/ParseConstants.swift b/Sources/ParseSwift/ParseConstants.swift index d9778dcc1..445a67e86 100644 --- a/Sources/ParseSwift/ParseConstants.swift +++ b/Sources/ParseSwift/ParseConstants.swift @@ -10,7 +10,7 @@ import Foundation enum ParseConstants { static let sdk = "swift" - static let version = "5.8.0" + static let version = "5.8.1" static let fileManagementDirectory = "parse/" static let fileManagementPrivateDocumentsDirectory = "Private Documents/" static let fileManagementLibraryDirectory = "Library/" diff --git a/Sources/ParseSwift/Types/Pointer.swift b/Sources/ParseSwift/Types/Pointer.swift index 043e16731..9930ecd49 100644 --- a/Sources/ParseSwift/Types/Pointer.swift +++ b/Sources/ParseSwift/Types/Pointer.swift @@ -115,13 +115,22 @@ public extension Pointer { Task { var options = options options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) + + let method = API.Method.GET let path = API.Endpoint.object(className: className, objectId: objectId) - await API.NonParseBodyCommand(method: .GET, - path: path) { (data) -> T in + let params: [String: String]? = { + guard let includeKeys = includeKeys else { + return nil + } + return ["include": "\(Set(includeKeys))"] + }() + let mapper = { (data) -> T in try ParseCoding.jsonDecoder().decode(T.self, from: data) - }.execute(options: options, - callbackQueue: callbackQueue, - completion: completion) + } + await API.NonParseBodyCommand(method: method, path: path, params: params, mapper: mapper) + .execute(options: options, + callbackQueue: callbackQueue, + completion: completion) } } }