Closed wtholliday closed 3 months ago
id
is an internal keyword for all Parse classes and should not be used to name a property or else you will get unexpected behavior. This is not just for ParseSwift, but all of the SDKs. You can use a name like localId
, key names you are not suppose to use are: https://github.com/netreconlab/Parse-Swift/blob/c0a3a452a20d9f3ab9cb2a2ea790d0359a3beca0/Sources/ParseSwift/Coding/ParseEncoder.swift#L75-L82
Why skip fields inside a struct which isn't a ParseObject? Seems like it could store them without any issues, since they are just represented as json strings on the server, right?
If you think you have a better solution, feel free to open a PR with your suggestion.
Reopening this, will see if I can provide a fix by the end of the week
Thanks, Corey! Discovering this the hard way was a huge pain.
I looked further into this and attempting to provide a fix now will cause more harm than good. The ParseEncoder
is tricky as there are a number of properties that shouldn't be sent to the server.
As a workaround, you can do any of the following:
ParseObject
(the string will be stored as-is and won't skip keys). You can then decode your JSON string whenever you fetch your object from the server. You could then add another property with a getter and setter that decodes the string in the getter and encodes the string on the setter similar to See #177 for fix
New Issue Checklist
Issue Description
Fields named "id" are skipped in nested objects.
Steps to reproduce
Actual Outcome
Fields named "id" are ignored and don't make it to the server.
Expected Outcome
Fields named "id" (not in ParseObjects) should still be saved or an error should be reported so the user knows to rename the field.
Environment
Client
5.8.2
15.1 (15C65)
macOS
14.2.1 (23C71)
Server
4.5.0
Ubuntu
BackForApp
Database
MongoDB
3.6
BackForApp