Skip to content

select constraint only works on top level object #3381

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

Closed
adammaddox opened this issue Jan 16, 2017 · 5 comments
Closed

select constraint only works on top level object #3381

adammaddox opened this issue Jan 16, 2017 · 5 comments

Comments

@adammaddox
Copy link

adammaddox commented Jan 16, 2017

  • expected to reduce response size by specifying nested attributes in select using dot notation
  • assumed should work, according to this issue select() constraint is not applied to included objects #1567 and the subsequent PR
  • is this possible, or do i need to create cloud function to manually filter response?

Steps to reproduce

# 1. run query 
const Item = Parse.Object.extend("Item");
const query = new Parse.Query(Item);
query.select("name", "total", "client.name"); 
query.find().then(
  results => { console.log(Object.keys(results[0].get("client")).length);   },
  error    => { console.log(error); }
);

# 2. observe console (expect 1 key, get 3 keys)
> 8

Expected Results

response = { name: 'bacon', total: 100, client: { name: 'ham' } }

Actual Outcome

response = { name: 'bacon', total: 100, client: { name: 'ham', address: 'abc', town: 'xyz'  } }

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.3.2
    • Operating System: OSX
    • Hardware: MBP
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): heroku (parse-server), localhost (client)
  • Database

    • MongoDB version: 3.0.12
    • Storage engine: MMAPv1
    • Hardware: 7.5Gb mem
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

You can turn on additional logging by configuring VERBOSE=1 in your environment.


# tested the following keys (with select("client") and without
- client,itemNo,itemDate,dueDate,balanceDue,total,client.name
- itemNo,itemDate,dueDate,balanceDue,total,client.name


# actual logs from response

2017-01-16T00:40:4sadf+00:00 app[web.1]: } method=GET, url=/parse/classes/Item, host=sdf.herokuapp.com, connection=close, pragma=no-cache, cache-control=no-cache, origin=http://localhost:3000, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.22395 Safari/537.36, content-type=text/plain, accept=*/*, dnt=1, referer=http://localhost:3000/items, accept-encoding=gzip, deflate, br, accept-language=en-US,en;q=0.8,sl;q=0.6,fr;q=0.4, x-request-id=86712406-2022-40e9sdfsdfab2323, x-forwarded-for=123.123.123.123, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=0, x-request-start=312321312, total-route-time=0, content-length=446, __type=Pointer, className=Account, objectId=123, $ne=true, docType=0, keys=**client,itemNo,itemDate,dueDate,balanceDue,total,client.name**, limit=100, order=-itemDate

2017-01-16T00:40:40.853163+00:00 app[web.1]: �[36mverbose�[39m: RESPONSE from [GET] /parse/classes/Item: {
2017-01-16T00:40:40.853166+00:00 app[web.1]:   "response": {
2017-01-16T00:40:40.853167+00:00 app[web.1]:     "results": [
2017-01-16T00:40:40.853168+00:00 app[web.1]:       {
2017-01-16T00:40:40.853171+00:00 app[web.1]:         "objectId": "Q1OLsQNp",
2017-01-16T00:40:40.853172+00:00 app[web.1]:         "client": {
2017-01-16T00:40:40.853172+00:00 app[web.1]:           "shipFob": "",
2017-01-16T00:40:40.853173+00:00 app[web.1]:           "shipVia": "",
2017-01-16T00:40:40.853173+00:00 app[web.1]:           "shippingAddress2": "",
2017-01-16T00:40:40.853173+00:00 app[web.1]:           "contact": "",
2017-01-16T00:40:40.853174+00:00 app[web.1]:           "address2": "",
2017-01-16T00:40:40.853175+00:00 app[web.1]:           "remoteId": "057fb50a---8856-16a17edb9d31",
2017-01-16T00:40:40.853175+00:00 app[web.1]:           "shipAmount": 0,
2017-01-16T00:40:40.853175+00:00 app[web.1]:           "shipTracking": "",
2017-01-16T00:40:40.853176+00:00 app[web.1]:           "shippingAddress1": "",
2017-01-16T00:40:40.853176+00:00 app[web.1]:           "name": "Daenerys Targaryen",
2017-01-16T00:40:40.853177+00:00 app[web.1]:           "email": "",
2017-01-16T00:40:40.853177+00:00 app[web.1]:           "address1": "",
2017-01-16T00:40:40.853177+00:00 app[web.1]:           "shippingName": "",
2017-01-16T00:40:40.853178+00:00 app[web.1]:           "address3": "",
2017-01-16T00:40:40.853178+00:00 app[web.1]:           "clientRemoteId": "-34b6--bb93-0a26ad560cee",
2017-01-16T00:40:40.853179+00:00 app[web.1]:           "shipDate": "",
2017-01-16T00:40:40.853179+00:00 app[web.1]:           "shippingAddress3": ""
2017-01-16T00:40:40.853179+00:00 app[web.1]:         },
2017-01-16T00:40:40.853180+00:00 app[web.1]:         "balanceDue": 8940,
2017-01-16T00:40:40.853180+00:00 app[web.1]:         "itemDate": "2016-11-01",
2017-01-16T00:40:40.853183+00:00 app[web.1]:         "total": 8940,
2017-01-16T00:40:40.853184+00:00 app[web.1]:         "itemNo": "INV0hg7",
2017-01-16T00:40:40.853184+00:00 app[web.1]:         "createdAt": "2016-11-:56:15.429Z",
2017-01-16T00:40:40.853185+00:00 app[web.1]:         "updatedAt": "2017-01-:59:06.978Z",
2017-01-16T00:40:40.853185+00:00 app[web.1]:         "dueDate": "2016-12-01"
2017-01-16T00:40:40.853185+00:00 app[web.1]:       },
2017-01-16T00:40:40.853186+00:00 app[web.1]:       {
2017-01-16T00:40:40.853186+00:00 app[web.1]:         "objectId": "23",
2017-01-16T00:40:40.853186+00:00 app[web.1]:         "client": {
2017-01-16T00:40:40.853186+00:00 app[web.1]:           "shipFob": "",
2017-01-16T00:40:40.853187+00:00 app[web.1]:           "shipVia": "",
2017-01-16T00:40:40.853187+00:00 app[web.1]:           "shippingAddress2": "",
2017-01-16T00:40:40.853188+00:00 app[web.1]:           "contact": "",
2017-01-16T00:40:40.853188+00:00 app[web.1]:           "address2": "",
2017-01-16T00:40:40.853188+00:00 app[web.1]:           "remoteId": "-508f-4d06-ae2e-89e45289de90",
2017-01-16T00:40:40.853189+00:00 app[web.1]:           "shipAmount": 0,
2017-01-16T00:40:40.853189+00:00 app[web.1]:           "shipTracking": "",
2017-01-16T00:40:40.853189+00:00 app[web.1]:           "shippingAddress1": "",
2017-01-16T00:40:40.853190+00:00 app[web.1]:           "name": "Sansa Stark",
@flovilmart
Copy link
Contributor

@adammaddox

This feature is heavily tested here:

https://github.com/ParsePlatform/parse-server/blob/master/spec/ParseQuery.spec.js#L2617

Can you please check what's different,

From the request, I can see in the keys list, there is client as well, not sure how it should behave as you have client AND client.name, can you try removing client from the list and see the outcome?

@adammaddox
Copy link
Author

adammaddox commented Jan 16, 2017

thanks @flovilmart

Good catch on the request. I tested a few variations, with and without "client" in the select array, same result for both.

After looking over the spec (thanks for the link), the issue looks to be related to datatypes. I have the Class Item, which has a object column client, not a pointer to a related class.

screen shot 2017-01-16 at 2 41 21 pm

@flovilmart
Copy link
Contributor

Uhm... not sure we support that case then. Do you wanna try implement it?

@stale
Copy link

stale bot commented Sep 18, 2018

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.

@stale stale bot added the wontfix label Sep 18, 2018
@stale stale bot closed this as completed Sep 25, 2018
@zivchen
Copy link
Contributor

zivchen commented Aug 27, 2019

@adammaddox did you manage to solve this?

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

3 participants