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

Add $rename update operator #271

Merged
merged 6 commits into from
Mar 17, 2023
Merged

Conversation

tatu-at-datastax
Copy link
Contributor

What this PR does:

Adds $rename general update operator

Which issue(s) this PR fixes:
Fixes #165

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review March 16, 2023 23:34
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner March 16, 2023 23:34
@tatu-at-datastax tatu-at-datastax changed the title (WIP) Add $rename update operator Add $rename update operator Mar 16, 2023
// If there is a value will be a modification (since source value will
// disappear), regardless of whether target changes
modified = true;
PathMatch dst = action.targetLocator().findOrCreate(doc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is document which has address sub-document like {"address" : {"address line" : "123 main st", "city" : "NYC", "state": "NY"}}
If the update request is to rename city to town, the sub-document fields (city and state) order will change as {"address" : {"address line" : "123 main st", "state": "NY", "city" : "NYC"}}? Is this the expected behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maheshrajamani As far as I can see, mongo docs state (and Atlas seem to implement it like so) that $rename is implemented as "$unset followed by $set"; and $set appends at the end.

So I think it would indeed be expected that field "moves" the way you describe; city removed, town appended.

@tatu-at-datastax
Copy link
Contributor Author

tatu-at-datastax commented Mar 17, 2023

One thing I may want to do is to check the case of 'src == dst` -- looks like that needs to become an error too.

EDIT: done.

@tatu-at-datastax tatu-at-datastax merged commit 3e2c49b into main Mar 17, 2023
@tatu-at-datastax tatu-at-datastax deleted the tatu/165-add-rename-oper branch March 17, 2023 03:47
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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

Successfully merging this pull request may close these issues.

Implement general update operator $rename
3 participants