-
-
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
Parse.Query.find() returns Parse.Pointer[] instead of Parse.Object[] #5521
Parse.Query.find() returns Parse.Pointer[] instead of Parse.Object[] #5521
Comments
Thank you for the detailed report. Can you write a failing test? |
@RaschidGithub did you ever figure this one out? Interesting. I suspect that it is a misconfiguration on your part. Turning on verbose logging may help in tracking it down what is going on. If I have read your account properly, this is only happening with one class and not the others. You write: "This only happens on a specific class (Project in my case)", but then use 'Profile' everywhere else. |
Thanks @acinader , I've edited my description as I miswrote the sentence: it should read "... on a specific class ( I've turned on verbose, it's pasted on the issue description. I'm gonna try the test @dplewis suggested and get back to you with the result. I'll just have to figure out how that is done hehe. |
@dplewis so I forked the repo (I guess I need to run my local server from the |
If you got the tests running and passing, write a new test to reproduce your issue. If your new test fails then create a Pull Request. https://github.com/parse-community/parse-server/blob/master/CONTRIBUTING.md |
@RaschidGithub I've just noticed in your logs that you are sending a parameter called "department" but you are not using this parameter in the function you included in your issue description. I am just wondering if you really included the whole code of the function. Can you please double check? |
@davimacedo Yes, the cloud function was supposed to do some more complex querying, but as it wasn't working I reduced it to just one line ( |
Can you try the code below to see what happens? Parse.Cloud.define('department:getMembers', request => { The idea is to not use the Profile class just to make sure that the problem is in the API and not in the code. |
@RaschidGithub I wrote a test case and it passed. I don't think this is an API issue. |
Exact same result @davimacedo ... this is so weird. I even tried with and without the masterkey just because and still failing. I'm starting to thing I may have broke something on maybe on the mongodb, the strange thing is that this happens also on the remove server on [back4app](https://back4app.com]. Thanks for the case @dplewis . I know, this code is too simplt to cause such an issue. I'm gonna start testing my git history and see If I can when it stopped working. |
I'm noticing something in the logs that I left out before: the server fetches the complete Objects
|
I'm following your lead @davimacedo and it turns out that the request works fine when I don't register the subclass
|
Does the test case I wrote match the issue you are having? If not please write a test case as I have mentioned before. When in doubt you can debug the code base. |
Ok guys, so I've narrowede the problem and I'm able to give the instructions to reproduce the bug (should I update the main issue description above?).
@dplewis I'm not sure how to write a test case (I have null experience on it), but may be it's something like this (If you run this code you'll get the issue as described). It seems that the line to init the array prop to
|
Check out the Contributing Guide Add your code here PS: This isn't a typescript project |
@RaschidGithub if you remove the line you mentioned, does it work? Why do you need this line? I think it can be just removed. |
Yes, it does work if I remove the mentioned line. It's not a critical line, its porpuse is to initialize the value of the property For now I'm using this workaround, but I don't think this is how it's supposed to work:
I hope to get the time this weekend to put my hands on that Jasmine test. |
I'm on 2.x and also noticed initializer code in constructors caused this same issue. We have a large team and I put in every class constructor: |
Hey @dplewis so I finally wrote this test case in ParseCloudTest.js and it fails:
Please take a look and let me know what's next. |
@dplewis @davimacedo wondering if this has been missed? |
@TomWFox I can look into it. It hasn't been addressed |
@RaschidJFR Thanks for the test case and sorry for the late reply. I think i figured out why your test was failing.
Can you write a test for your original issue or are you still experiencing it? |
Yeah, I'm still having the problem. That's the test case for my original issue. Need me to write a different test case? |
A test case for the array of pointers issue would be great. The test you already wrote doesn't cover that as you are using |
Sorry for my late reply. You're right, I had written that part before but I may have discarded it. I'll check it again and share a test. |
@dplewis So wrote a more robust test case. For this, second and third cases fail. So far I've found this:
PS. I'm not sure where this test should go, whether in the server's repo or in the sdk's. For now I put it into
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Yes, I can tackle this. Just give me a starting point to look. |
https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseObject.js#L1704 In fromJSON creates a new object. Your SubClass creates pendingOps. The solution is to delete the pending ops when creating a new object. I’m not sure this will have side effects when using subclasses. |
@RaschidJFR Which one of the following makes sense?
|
I think the second case makes more sense being the value in fromJSON the lasting value. |
Feel free to submit a PR on the JS SDK. |
* Test failing with error "Expected 'default' to be 'foo'." * `jasmine.DEFAULT_TIMEOUT_INTERVAL` was increased to `10000` because the first cases often failed when starting integration testing. Related to issue parse-community/parse-server#5521
I created a PR. It is failing some tests but you'll get the general idea. I'll continue on it next week. |
Guys. how to solve this problem??? I have to install the newest SDK still won't work.. My find() method return a object not a array.. wired.. |
@thunderwin can you share a bit of code? |
I am having same issue with custom class
This returns an array of pointers. |
Any updates on this? I am encountering the same error. |
It has been a long time I don't remember if I had an initial value. How can I check if my class has an initial value ? |
Something like this would be setting initial values: class SubclassArrayProp extends Parse.Object {
constructor(attributes) {
super('SubclassArrayProp', attributes);
this.myArray = ['some', 'initial', 'values']; // <- like this
}
get myArray() { return this.get('myArray'); }
set myArray(val) { this.set('myArray', val); }
} |
I did not check this yet but one of my old parse instances doing same thing. In my 2.6.5 V server there is no default value option when I am adding a new column from parse-dashboard but still getting pointers when I query a relation. |
@dplewis @davimacedo @mtrezza I'm going to pick this one up as I "think" ran into a similar issue while testing Parse-Swift and I think I know how to replicate it.
I'll open a PR later today with a failing test case and hopefully a fix (I haven't investigated where the problem is yet). If you have any leads, let me know |
Small update... I think the issue may have something to do with this comment: Lines 63 to 96 in e6ac3b6
As it led me to switch the order (to alphabetical, wasn't alphabetical in my example above) of the names of the fields which resulted in the following change my last scenario above:
|
Reopening as the original issue hasn't been addresssed. |
Hello! async function getParentCategory(parent) {
let objectId;
if (typeof parent === 'string') {
objectId = parent;
} else {
objectId = parent.id;
}
const query = new Parse.Query('ParentCategory');
query.equalTo('objectId', objectId);
const [object] = await query.find();
return object;
}
Parse.Cloud.afterLiveQueryEvent('Categories', async function(request) {
const parent = await getParentCategory(request.object.get('parentId'));
console.log('>>> parent ', object);
request.object.set('parent', parent);
// Why Pointer?
console.log('>>> object ', request.object);
}); First log parent is ParseObject I used Flutter sdk and in App I receive only Pointer with just id but not whole parent object. What I did wrong? |
@NuclleaR It may or it may not be related. I think there's some info missing to have a better diagnose, like the implementation of the involved classes and how you are registering subclasses. Also console output would help. You should write a test case or a minimal code block in a blank project to test if the problem can be reproduced and is in fact related to this issue. Go ahead and share it here if you find it so. |
I'm having the same issue. I have Objects that have relations to one or more _User(s). Take the example below, Car class Object has an
Note: This is taken straight out of the REST API documentation. All Objects stored on server have been made via REST API, and verified in Dashboard. This API call, returns me all This can be tested on any running Parse Server v2.3.3 up to v3.6.0 where you have a custom Object with relations pointing to another Object. Adding |
@yozef I think you have a different issue than the op. If you are trying to query a relation field try
|
@NuclleaR I can replicate your issue and am working on a fix |
Issue Description
When running a simple query on a class from cloud code, the result is an array of pointers to class objects instead of an array of actual objects. When the same query is run on the client it works ok.
This only happens on a specific class (
Profile
in my case), the same query on any other class returns the expected output.Steps to reproduce
Call this cloud function function for a certain class (in this case
Profile
):Expected Results
If I run the same query from the client:
new Parse.Query(Profile).find();
, what I get is a list of Parse Objects as expected:Actual Outcome
... but when run from cloud code I'm getting just pointers instead of actual objects!:
Environment Setup
Server
Database
Logs/Trace
Some more code
For what it's worth, this is the code for the class
Profile.ts
.The text was updated successfully, but these errors were encountered: