-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow mixed environment of server generated and custom objectId #220
Comments
Do I miss any security or other reason of that |
I don’t fully understand what’s being proposed. It seems there are multiple topics mentioned.
This defeats the purpose of having a unique objectId IMO as it’s no longer unique across tables and therefore no longer unique Related discussions: |
A PR to allow a mixed environment should probably follow the ideas mentioned in parse-community/Parse-SDK-JS#1309 (comment) Mainly, adapting components of the Flutter SDK. Thinking about this from a high level, you would leave the If this is something you would like to try, feel free to open a PR |
As we already exchanged some discussion regarding this in past and I went through the links I believe this does not need to be very complicated. In principle, the server already does support the mixed environment and it decides based on /// Specifies if a `ParseObject` has been saved.
public var isSaved: Bool {
if !ParseSwift.configuration.allowCustomObjectId {
return objectId != nil
} else {
return /*objectId != nil &&*/ createdAt != nil
}
} Unless I am missing anything the behaviour of server and SDK would stay the same. The SDK's users have already now to set
And for
And that does not seems to interfere with any test cases and linked discussion as far I understand things right. |
Where do you see this at?
This will have to be shown through the CI and even if none of the tests fail, it doesn't mean something isn't missed. |
You and Manuel mentioned it here: with reference to JS SDK , where I understand that the JS SDK also do not check if objectId exists when I also did run the modified fork and have found it behaving correct. I cannot guarantee that anything isn't missed, but I could help with the test cases, should any new be needed. |
in your comment you state “server” and then say “it”, implying this is done on the server side. Manuel and I were talking about the client SDKs in your link.
The SDKs are already aligned. The JS SDK does check for objectID. The lines I think you meant to reference are below: https://github.com/parse-community/Parse-SDK-JS/blob/d196e7f4f861aa76822c59ccb78352fe0bdda80c/src/ParseObject.js#L2402 In my initial response. I referenced parse-community/Parse-SDK-JS#1309 (comment). If you look two comments above, he says parse-community/Parse-SDK-JS#1309 (comment):
the comment above is a correct statement which is why I responded to your original comment with: https://community.parseplatform.org/t/both-custom-and-generated-objectid-in-one-project/1812/2?u=cbaker6 This makes sure developers do the correct thing when using custom objectId. Until the conversation is resolved on the JS side, I don’t see a reason to take the SDKs out of alignment as the change can lead to developers submitting issues because they think custom objectId is behaving incorrectly. |
I apologise, the SDK is deciding if it is POST or PUT, not the server and indeed I missed the line 2402. You are correct that the SDKs are aligned then. Perhaps to respond on the comment, I unfortunately found that the mixed behaviour would save in my case:
We could argue that my database schema should be different, but as I am not only one who would like to use mixed environment I can imagine multiple use cases out there. So when I was investigating and testing the mixed behaviour, I found it working as intended from the server side (apart from the I agree that it makes sure developers do the correct thing. But I also find that "correct thing" relative, as mentioned in JS discussion it force to use always custom ids and I will continue on the JS side then to clarify the need there. I hope I clarified the need from my side well? |
Looking at the commit I understand that the developers will have to set I wonder if it would not be simpler to keep I understand this is a bigger change, but it could be implemented together with current solution as an intermediate phase as it would not be in conflict with previous guard statements. What do you think? If you agree I could try to add this functionality. |
It sounds like you are proposing to open a new PR to implement this? If so, feel free. You will also need to add and modify the necessary test cases to assess corner cases. |
I will try to continue on the customObjectId branch to keep also your changes. With the test cases I might need some guidance, let's see. |
You should branch from the main so merge conflicts aren't created |
New Feature / Enhancement Checklist
Current Limitation
Currently it is not possible to have mixed environment of custom and server generated objectId. In the case where
User
and user'sProfile
are two different objects in the database (keeping public data only in Profile) there is a need of reference field between these two related objects (Pointer or objectId String).This is making it complicated in certain scenarios. For example some third object, let it be
Group
has a list of participants[objectId]
or Pointers. When the group gets deleted and the cloud code function would like to send a message to each remaining participant, it needs to fetch eachProfile
's data to get relatedUser
's objectId to be able to set the ACL of the "group deleted" message object only for that recipient.Feature / Enhancement Description
With
allowCustomObjectId = true
allow mixed environment so that it is possible to set the same objectId for multiple objects in different classes. This allowsUser
andProfile
to have the same objectId and there will be no need to fetch additional objects to set the ACL properly as mentioned in the above scenario, reducing also the size of the objects in the database and need of additional indexes on reference fieldExample Use Case
For simple test I removed the
if
check onsaveCommand()
and it works as intended, having the need of not-nilcreatedAt
if the object should be updated.lsmilek1@b3346df
Leaving
createdAt = nil
and setting custom objectId to already existing value behaves as intended:Alternatives / Workarounds
As mentioned, available workaround is adding extra fields and indexes to the objects and therefore additional load on the server at big scale. In example of
User
andProfile
it is also easier to read that certain object belongs together3rd Party References
The text was updated successfully, but these errors were encountered: