Pointer.fetch(includeKeys:....) doesn't include keys? #128
Replies: 3 comments 3 replies
-
|
Nice find! It looks like it was missed. Can you open a pull request with the fix? The code you highlighted needs “params” like Parse-Swift/Sources/ParseSwift/API/API+Command.swift Lines 496 to 504 in 5f2c5f4 can you also add test cases here https://github.com/netreconlab/Parse-Swift/blob/main/Tests/ParseSwiftTests/ParsePointerTests.swift |
Beta Was this translation helpful? Give feedback.
-
|
I've adjusted the code to account for it! |
Beta Was this translation helpful? Give feedback.
-
|
Am struggling a little with the tests. I can't add a property such as: struct GameScore: ParseObject {
//: These are required by ParseObject
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var originalData: Data?
//: Your own properties
var points: Int
var other: Pointer<GameScore>?
var others: [Pointer<GameScore>]?
var score: GameScore? <------NEW
//: a custom initializer
init() {
self.points = 5
}
init(points: Int) {
self.points = points
}
}as this gives the error But I also couldn't create a new struct like: struct GameScore: ParseObject {
//: These are required by ParseObject
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var originalData: Data?
//: Your own properties
var points: Int
var other: Pointer<GameScore>?
var others: [Pointer<GameScore>]?
var game: Game?
//: a custom initializer
init() {
self.points = 5
}
init(points: Int) {
self.points = points
}
}
struct Game: ParseObject {
//: These are required by ParseObject
var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var originalData: Data?
//: Your own properties
var points: Int
//: a custom initializer
init() {
self.points = 5
}
init(points: Int) {
self.points = points
}
}as I get an error of testIncludeKeysFetch(): failed - Should encode/decode. Error keyNotFound(CodingKeys(stringValue: "points", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "game", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"points\", intValue: nil) (\"points\").", underlyingError: nil))I was trying to follow the same methodology as |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just wanted to check whether the below function is working as intended.
/** Fetches the `ParseObject` *asynchronously* and executes the given callback block. - parameter includeKeys: The name(s) of the key(s) to include. Use `["*"]` to include all keys. - parameter options: A set of header options sent to the server. Defaults to an empty set. - parameter callbackQueue: The queue to return to after completion. Default value of .main. - parameter completion: The block to execute when completed. It should have the following argument signature: `(Result<T, ParseError>)`. - note: The default cache policy for this method is `.reloadIgnoringLocalCacheData`. If a developer desires a different policy, it should be inserted in `options`. */ func fetch(includeKeys: [String]? = nil, options: API.Options = [], callbackQueue: DispatchQueue = .main, completion: @escaping (Result<T, ParseError>) -> Void) { Task { var options = options options.insert(.cachePolicy(.reloadIgnoringLocalCacheData)) let path = API.Endpoint.object(className: className, objectId: objectId) await API.NonParseBodyCommand<NoBody, T>(method: .GET, path: path) { (data) -> T in try ParseCoding.jsonDecoder().decode(T.self, from: data) }.execute(options: options, callbackQueue: callbackQueue, completion: completion) } }It looks like the parameter includeKeys is not actually being used in the function, and so isn't fetching the contents of any nested objects.
For example's sake, I have the following structs:
So I should be able to do the following:
but unfortunately it shows up as
nilIf I forcefully fetch (i.e.
meta.school?.fetch()), it correctly prints out the school name.Beta Was this translation helpful? Give feedback.
All reactions