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

[Bug]: The Update query fails to update for all matching Document in mongo #9648

Closed
1 task done
RakshaKShetty opened this issue Dec 8, 2021 · 6 comments · Fixed by #9975
Closed
1 task done

[Bug]: The Update query fails to update for all matching Document in mongo #9648

RakshaKShetty opened this issue Dec 8, 2021 · 6 comments · Fixed by #9975
Assignees
Labels
Bug Something isn't working Critical This issue needs immediate attention. Drop everything else Datasources Issues related to configuring datasource on appsmith Mongo Issues related to Mongo DB plugin Needs Triaging Needs attention from maintainers to triage Query & JS Pod Issues related to the query & JS Pod Release

Comments

@RakshaKShetty
Copy link

RakshaKShetty commented Dec 8, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When user try to update all the matching document at once the update happens only for 1 data in the mongo database
LOOM DEMO

Steps To Reproduce

  1. go to the database
  2. add the mongo database
  3. Select the update query
  4. add the query in such a way that the user is trying to update 2 records with the same name
  5. Now select the All matching documents in the limit dropdown
  6. Run the query
  7. The update happens for only 1 data

Environment

Production

Version

Cloud

@RakshaKShetty RakshaKShetty added Bug Something isn't working Datasources Issues related to configuring datasource on appsmith High This issue blocks a user from building or impacts a lot of users Release Needs Triaging Needs attention from maintainers to triage Mongo Issues related to Mongo DB plugin labels Dec 8, 2021
@github-actions github-actions bot added Query & JS Pod Issues related to the query & JS Pod Actions Pod labels Dec 8, 2021
@Nikhil-Nandagopal Nikhil-Nandagopal added Critical This issue needs immediate attention. Drop everything else and removed High This issue blocks a user from building or impacts a lot of users labels Dec 21, 2021
@leotom2000
Copy link
Contributor

Able to simulate the issue

@Nikhil-Nandagopal Nikhil-Nandagopal added Good First Issue Good for newcomers Critical This issue needs immediate attention. Drop everything else and removed Critical This issue needs immediate attention. Drop everything else Good First Issue Good for newcomers labels Dec 23, 2021
@leotom2000
Copy link
Contributor

leotom2000 commented Dec 23, 2021

Issue Resolution Summary :
There were two findings causing this issue.
(1) UPDATE_LIMIT should be updateMany.Limit instead of update.Limit , only then it may parse and set the multi attribute as true, earlier it was always false. Made that code change.
(2) "$set" was handled in code to resolve the issue, also found that it can be set as an user input, need to discuss and finalize.

@close-label close-label bot added the QA Needs QA attention label Dec 31, 2021
@leotom2000 leotom2000 reopened this Dec 31, 2021
@RakshaKShetty
Copy link
Author

RakshaKShetty commented Jan 11, 2022

@leotom2000 i could repro the issue so reopening the issue
LOOM DEMO

@RakshaKShetty RakshaKShetty reopened this Jan 11, 2022
@RakshaKShetty RakshaKShetty removed the QA Needs QA attention label Jan 11, 2022
@leotom2000
Copy link
Contributor

Described below the findings about updating a document in Mongo.
As per docs : https://docs.mongodb.com/manual/reference/operator/update/
-- To update a document, MongoDB provides update operators, such as $set, to modify field values.
-- Some update operators, such as $set, will create the field if the field does not exist.

so the syntax like " $set: { "size.uom": "in", status: "P" }," needs to be followed while doing the update.
A guideline of the syntax is there in the field placeholder.

The below syntax will work instead of {"name" : "cycle"}
working syntax : {$set : {"name" : "cycle"} }

We need to follow the above working syntax because, the user need to be given options to all update operators like "$currentDate, $inc, $min, $max, $mul, $rename, $set,$ setOnInsert, $unset," as per https://docs.mongodb.com/manual/reference/operator/update/.

The above syntax would not have worked earlier since there was an issue and was then fixed.
So no code change is required at this time, please test it with the above guideline and let us know the update.

@leotom2000 leotom2000 added the QA Needs QA attention label Jan 12, 2022
@RakshaKShetty
Copy link
Author

@leotom2000 I tried the scenario which you explained and it is working

@prapullac
Copy link
Contributor

Based on the above comment by @RakshaKShetty we can close the issue

@prapullac prapullac removed the QA Needs QA attention label Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Critical This issue needs immediate attention. Drop everything else Datasources Issues related to configuring datasource on appsmith Mongo Issues related to Mongo DB plugin Needs Triaging Needs attention from maintainers to triage Query & JS Pod Issues related to the query & JS Pod Release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants