-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Mongo explain results incorrectly returning an object instead of an array of objects #7442
Comments
Thanks for opening this issue. Is this an enhancement or a bug? |
I would label this as a bug. The reason for this is in JS because the language isn’t strongly typed, but from an implementation standpoint, explain should have always returned an array since every other query returns an array when using find. The bug was discovered because of its use in the Swift SDK which is strongly typed https://community.parseplatform.org/t/explain-result-in-parseswift/1557/2?u=cbaker6 |
Isn't the ObjC SDK also strongly typed? How is that solved there? |
I can check, but from memory, I don’t think the Objc SDK has the ability to explain |
I think you are right, I just looked through it. |
Do you mean that a change will inevitable include a breaking change for the JS SDK? Or is there anything broken currently in the JS SDK? I assume you mean the breaking change of
returning an array instead of an object?
Is this related to |
Yes, plus, any dev who uses Mongo and explain will have to modify their code no matter if they use JS or or REST directly. I think the Flutter SDK might use explain also in which it will probably break. The only SDK that won’t break is the Swift SDK because I never conformed to the bug
Kind of, first should automatically take the first index of results on the client side. I added a test on this for the server which is why I say the PR in the JS SDK is needed. Using find should return an array. The easiest way to compare is looking at the implementation in Swift: |
Before we weigh breaking all SDKs vs. making the Swift SDK conform to the "bug" - would it be possible at all to make the Swift SDK conform? |
Doing this would break the Postgres implementation in which I setup correctly on the server side #6506. In its current form (before this PR), only Mongo or Postgres explain can work on strongly typed SDKs, not both as the Mongo explain was originally coded incorrectly |
My point is, the Mongo storage adaptor is disobeying the correct sending of results, particularly when using JSON. when developing the Swift SDK I never conformed to bugs as long as I knew it was a bug originally. Of course, I could have introduced bugs which should be fixed over time. |
Yes, I understand your point, it makes sense to improve these things. I am trying to understand the implication of such a change. If it breaks only developer code, then this is just another breaking change. But if it breaks SDKs, we may need to prepare these SDKs before making the change in the server. It would be interesting to know which SDKs exactly this would break. |
From memory, the JS, Swift (non-breaking), and Flutter SDKs have explain. I don’t think the others have it, but I’m on mobile, so we will have to confirm |
For the JS SDK, this will not break the SDK itself, but breaks it's testcases. In addition, if devs were using find explain they will need to fix their code to use an array instead of an object. It seems the only SDKs that have the ability to |
Then I think we can go ahead with a PR and highlight the breaking change. |
I classified this as a bug with severity S4 (small / trivial):
|
Another workaround is to write an |
New Issue Checklist
Issue Description
Mongo explain results incorrectly returning an object instead of an array of objects. This causes an issue for SDKs that use strongly typed languages as
results
(plural) should always be an array.This will break any SDK that isn't strongly typed. In the case of the JS SDK, it will break current testcases instead (PR for JS SDK here.
In addition, this brings up another issue in the JS SDK which doesn't supportexplain
forfirst
queries.Originally discussed on community.parseplatform.org
Steps to reproduce
Run any explain query.
Actual Outcome
A single explain object.
Expected Outcome
An array of explain objects that have only 1 object.
Failing Test Case / Pull Request
Environment
Server
4.5.0
and latestmaster
docker linux
self hosted
Database
MongoDB
4.4
self hosted
Client
Swift SDK
1.8.3
Logs
The text was updated successfully, but these errors were encountered: