Closed
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
Calling .add
multiple times on a relation adds only the object mentioned in the first call.
Steps to reproduce
it('can do consecutive adds', done => {
const ChildObject = Parse.Object.extend('ChildObject');
const childObjects = [];
for (let i = 0; i < 2; i++) {
childObjects.push(new ChildObject({ x: i }));
}
const parent = new Parse.Object('ParentObject');
parent.save().then(parentAgain => {
Parse.Object.saveAll(childObjects)
.then(() => {
for (const child of childObjects) {
parentAgain.relation('child').add(child);
}
return parentAgain.save();
})
.then(() => {
return parentAgain.relation('child').query().find();
})
.then(results => {
assert.equal(results.length, 2);
const expectedIds = new Set(childObjects.map(r => r.id));
const foundIds = new Set(results.map(r => r.id));
assert.deepEqual(expectedIds, foundIds);
done();
});
});
});
Actual Outcome
Only the first child object is added to the relation
Expected Outcome
Both of the child objects should be added to the relation
Environment
Server
- Parse Server version: alpha
- Operating system: Ubuntu
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local
Database
- System (MongoDB or Postgres): MongoDB
- Database version:
6.0.11
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local
Client
- Parse JS SDK version: alpha