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

Calling .add multiple times on relations is broken #2056

Closed
4 tasks done
mstniy opened this issue Nov 23, 2023 · 4 comments · Fixed by #2078
Closed
4 tasks done

Calling .add multiple times on relations is broken #2056

mstniy opened this issue Nov 23, 2023 · 4 comments · Fixed by #2078
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mstniy
Copy link
Contributor

mstniy commented Nov 23, 2023

New Issue Checklist

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

Logs

Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

mstniy added a commit to Ocell-io/Parse-SDK-JS that referenced this issue Nov 23, 2023
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Nov 27, 2023
mstniy added a commit to Ocell-io/Parse-SDK-JS that referenced this issue Nov 27, 2023
mstniy added a commit to Ocell-io/Parse-SDK-JS that referenced this issue Jan 21, 2024
mstniy added a commit to Ocell-io/Parse-SDK-JS that referenced this issue Jan 21, 2024
mstniy added a commit to Ocell-io/Parse-SDK-JS that referenced this issue Jan 25, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.3.1-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Feb 15, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Mar 17, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
3 participants