Skip to content

save call on object with beforeSave trigger removes the data of pointer fields #1238

Closed
@sud80

Description

@sud80

Environment Setup

nodejs: 4.4.0
parse-server: 2.2.2

Description of the issue

When the beforeSave trigger for an object is present, the save call overwrites the pointer fields with only the object id even thou' the pointer field had fetched object before calling save.

Steps to reproduce

new Parse.Query('Person')
  .first()
  .then(person => {    
    console.log(person.createdAt, person.get('name')); // prints correctly
    const account = new Parse.Object('Account', {person});
    console.log(account.get('person').createdAt, account.get('person').get('name')); // prints correctly
    return account.save();
  })
  .then(account => {
    // prints correctly only if there are no beforeSave triggers.
    console.log(account.get('person').createdAt, account.get('person').get('name')); 
  });

For the above, I would ideally expect the console.log to print both person's createdAt and name in all the three logs. But the last console.log prints the values correctly only if beforeSave trigger is not present. If beforeSave trigger present, then it just contains the pointer value and loses the object data.

Logs/Trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions