Skip to content

select constraint only works on top level object  #3381

Closed
@adammaddox

Description

@adammaddox
  • 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",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions