-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Using Query.select() will break ParseObject.has() on undefined field from 2.5.1 #3999
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
Comments
Thanks for reporting the issue! We’ll have a look shortly! |
This affected my application also I had to return from version to 2.5.0 because I can not get certain data |
@adirgan, @promisenxu I just added a test, and waiting for CI to complete, but so far, this test works as expected. #4004. Can you please tell me where this test doesn't match your issue? Also, can you post the logs when running with VERBOSE=1? |
i had same problem, when i use select and the field is pointer type and the value is undefined. the new parse version returns an JSON with all fields of this pointer with undefined value. Expected are the selected field return an undefined value not an JSON object with undefined values on the fields. |
So is it possible to tell me where my test is wrong?? |
On your test @flovilmart you have set an empty object on the field named 'field'. In my case, the value of the 'field' should be undefined to replicate the issue |
In my test, the obj has no value for the field key, and obj1 has an object. And it works as expected. Can you post and example test that fails at CI because I don’t get it |
I think its simple. You can add console.log(result.get('field')) on your test. In this case are expected undefined. In my case returns an json like {"__type":"Pointer","className":"OtherObject","objectId":undefined} and all of others fields have undefined value. If you need i can provide an screen with log with VERBOSE=1 |
But you realize that the obj.has(‘field’) works as expected right? |
@logicsb verbose logs of the query response:
|
I'd gladly resolve the issue if only I could reproduce it |
In my case the issue is:
hive: is a pointer to Hive and value is undefined on the parse-dashboard I don't know, but before update the parse version, "object" field does not apear on the response JSON because your value is undefined. i'm using select like query.select("object") I think before version of parse are correct, if "object" is undefined don't need send an empty object on the response. |
Can you provide some code/open a PR with a failing test please? |
I think i have found the situation to cause this issue: class Foo (name:String, status:String, content:String, object:Pointer< Foo>, user:Pointer<_User>)
if the object field is undefined this will return a JSON like:
|
@flovilmart @montymxb This is how I reproduced the issue. This is a JS-SDK issue
|
There was an issue in the JS-SDK where a query that selected sub-objects would cause the client to inject empty sub-objects at the parent levels in the selection path if an element in that path was not returned by the query. I believe that is the cause of the issues described here. I have submitted a pull request to the JS-SDK with a fix along with some test cases for the root cause of this: parse-community/Parse-SDK-JS#477 |
@dstarke, before we merge the JS fixes, I’ll add a test here to make sure he fix is efficient and we have no other regressions in here. |
@dplewis I ran your repro in the test suite, and it still didn't fail :/ Not sure how to go from there. |
Sorry for abandoning this thread - was dealing with some personal issues. I'm not sure what is the current status of this. It seems that parse-community/Parse-SDK-JS#477 should fix this? Let me try to create a test for this repo for this issue. |
@flovilmart Figure out how to write a failed test case for this issue - the caveat is to also select a field of the pointer field. Pull Request #4245 |
thanks for jumping back on it! We’ll review shortly and test against The fixed JS SDK :) |
Issue Description
Starting from Parse Server 2.5.1, if a query has Query.select() , calling .has() on the returned object with a selected field that's undefined will return true.
Steps to reproduce
var query = new Parse.Query('ClassName');
query.include('FieldName');
query.select('FieldName');
query.get('objectId', {useMasterKey: true}).then(result => {
// Assume FieldName is undefined for the returned object
result.has('FiledName'); // This will return true.
});
Expected Results
.has() on a field with undefined value should return false, which is the behaviour up to 2.5.0.
Actual Outcome
Return true.
Environment Setup
Server
Database
The text was updated successfully, but these errors were encountered: