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

Support dot-notation with $inc update operator #196

Merged
merged 3 commits into from
Feb 27, 2023

Conversation

tatu-at-datastax
Copy link
Contributor

What this PR does:

Supports dot-notation (nested paths) for $inc operator (currently only works on root-level properties).

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

Checklist

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

@tatu-at-datastax tatu-at-datastax self-assigned this Feb 27, 2023
@@ -23,7 +23,8 @@ public static PopOperation construct(ObjectNode args) {
List<PopAction> actions = new ArrayList<>();
while (fieldIter.hasNext()) {
Map.Entry<String, JsonNode> entry = fieldIter.next();
final String name = entry.getKey();
final String path = validateUpdatePath(UpdateOperator.POP, entry.getKey());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was missing verification we won't target _id -- would fail anyway as _id cannot be an Array, but Mongo catches immutability problem before structural difference.

*/
protected static String validateSetPath(UpdateOperator oper, String path) {
protected static String validateUpdatePath(UpdateOperator oper, String path) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed since now used by all update operators.

@tatu-at-datastax tatu-at-datastax changed the title (WIP) Support dot-notation with $inc update operator Support dot-notation with $inc update operator Feb 27, 2023
@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review February 27, 2023 19:21
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner February 27, 2023 19:21
Copy link
Contributor

@maheshrajamani maheshrajamani left a comment

Choose a reason for hiding this comment

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

LGTM

@tatu-at-datastax tatu-at-datastax merged commit 54a2666 into main Feb 27, 2023
@tatu-at-datastax tatu-at-datastax deleted the tatu/183-dot-notation-for-inc branch February 27, 2023 21:52
@vkarpov15
Copy link
Collaborator

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.

Support nested path ("dot notation") for $inc operator
3 participants