Skip to content
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

ACL is not fetched when I use "select" #571

Closed
Samigos opened this issue May 18, 2018 · 6 comments
Closed

ACL is not fetched when I use "select" #571

Samigos opened this issue May 18, 2018 · 6 comments

Comments

@Samigos
Copy link

Samigos commented May 18, 2018

Parse Server: 2.7.4

I have an or query and I want to add some additional constraints to it, like so:

var chatRoomQuery = Parse.Query.or(currentUserAsSenderChatRoomsQuery, currentUserAsReceiverChatRoomsQuery);

chatRoomQuery.include(["sender.school"], ["receiver.school"]);
chatRoomQuery.select("lastMessage", "lastMessageWasAddedAt", "senderChatRoomName", "receiverChatRoomName", "hasSenderLeft", "hasReceiverLeft", "sender.gender", "sender.school", "receiver.gender", "receiver.school");

As you can see, I use the select constraint... I realised though, that when select is being used, ACL is not a part of the fetched object(s), even if I explicitly add it, like so:

chatRoomQuery.select("ACL", lastMessage", "lastMessageWasAddedAt", "senderChatRoomName", "receiverChatRoomName", "hasSenderLeft", "hasReceiverLeft", "sender.gender", "sender.school", "receiver.gender", "receiver.school");

Any idea why's this happening? What could I do to as a workaround?

@flovilmart
Copy link
Contributor

This is a bug. Are you willing to write a failing Test and open a pull request with it? We’ll be able to fix it soon.

@Samigos
Copy link
Author

Samigos commented May 18, 2018

I want to, but I have no idea how! Is there a guide or something?

@flovilmart
Copy link
Contributor

@georgesjamous
Copy link

georgesjamous commented Jun 5, 2018

@i believe in Parse-Server, ACL include is enforced (as well as ObjectId, createdAt, updatedAt ..)
check : Line where key is enforced in Parse-Server

I think the problem resides in JS-SDK
here function handleSelectResult
specifically on select.forEach((field)
we are looping though the selected keys only.
Additional keys added by the server (in your case ACL) are ignored, but I don't think it should be fix here !.

I think the main issue is happening here
I am not sure why, but, for it to work otherAttributes should contain ACL but it may be filtered out by if (attr !== 'className' && attr !== '__type') {

I think, It is working for createdAt & updatedAt since the getter function in Parse.Object access the json directly.

@Samigos I just took a quick look, I am not sure that what I said is 100% correct. This could help you target the bug

I will take a stab at it in a couple of days if I have the time

@cipiripper
Copy link

cipiripper commented Aug 15, 2018

You can select ACL with a dumb workaround:

query.select([ '_rperm', '_wperm']);

This is how they are stored in MongoDB, and will be passed on to it. Mongo will return _rperm (read permissions) and _wperm (write permissions) for an object, and Parse will convert them into ACL, returning it to you.

@flovilmart
Copy link
Contributor

I pushed a fix, this is gonna be part of the next release of parse-server. ACL's will always be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants