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

Pointer fields can not be created in beforeSave trigger #1288

Closed
guptasachin25 opened this issue Mar 30, 2016 · 1 comment
Closed

Pointer fields can not be created in beforeSave trigger #1288

guptasachin25 opened this issue Mar 30, 2016 · 1 comment

Comments

@guptasachin25
Copy link

For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

"express": "~4.11.x",
"kerberos": "~0.0.x",
"parse": "~1.8.0",
"parse-server": "~2.2.0",

Steps to reproduce

  1. Create one object TestObject with single value with given beforeSave trigger.
  2. beforeSave Trigger creates a pointer field if not available
  3. Fetch same object and try to change non_pointer key and save
  4. BeforeSave trigger doesn't find old pointer field and recreated new pointer field.
exports.beforeSaveTestObject = request => {
   console.log('before Save test Object');
   var obj = request.object;
   console.log(obj);
   console.log(obj.get('point'));
   if (obj.get('point')) {
     return;
   }
   console.log('point not found');
   var TestObject1 = Parse.Object.extend('TestObject1');
   var newObj = new TestObject1({'key1': 1});

   return newObj.save().then((newObj) => {
     obj.set('point' , newObj);
   });
 }

Logs/Trace

Found a pointer column not in the schema, dropping it. TestObject point
Found a pointer column not in the schema, dropping it. TestObject point
before Save test Object
ParseObject { _objCount: 0, className: 'TestObject', id: 'w93hLKA3VZ' }
undefined
point not found
@guptasachin25
Copy link
Author

I did investigated this issue I found that any schema validation is done before beforeSave. For new objects schema is created during this step. If we add any field to beforeSave that is never updated in schema. I verified in mongo database SCHEMA table.

If we add schema validation after beforeSaveTrigger ran this works fine.

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

2 participants