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

Implement general update operator $rename #165

Closed
tatu-at-datastax opened this issue Feb 21, 2023 · 2 comments · Fixed by #271
Closed

Implement general update operator $rename #165

tatu-at-datastax opened this issue Feb 21, 2023 · 2 comments · Fixed by #271
Assignees

Comments

@tatu-at-datastax
Copy link
Contributor

tatu-at-datastax commented Feb 21, 2023

Another general-purpose array operator to implement is $rename. Its semantics are similar to $unset followed by $set (if that was allowed), so that:

  1. If target path exists, the value is overwritten
  2. If source path does not exist, operation does nothing (but does not fail)

Format is simple:

{ "$rename" : { "field1" : "newName1", .... , "fieldN", "newNamen" } }

Following error modes exist:

  1. _id either as source or target: cannot modify immutable property "_id"
  2. Same source and target (must differ)
  3. Attempt to move source to incompatible path

The last case occurs, for example when an attempt is madeto set a property on Array value: that is, target path points to something that is not possible to add: for example with

{ "x" : 3, "array" : [ 1 ] }

attempt to apply operation

{ "$rename" : { "x" : "array.x" }  }

would fail. Same is true for paths "through" atomic fields; only (sub)documents have properties.

@vkarpov15
Copy link
Collaborator

$rename isn't necessarily an array operator. I'd also put $rename as low priority, it is rarely used in my experience.

@tatu-at-datastax tatu-at-datastax changed the title Implement array update operator $rename Implement general update operator $rename Feb 21, 2023
@tatu-at-datastax
Copy link
Contributor Author

Thank you @vkarpov15 that was a copy-paste mistake (I know it's not array-specific).

I am creating issues based on @amorton's list; this is lower priority than my current work on dotted paths for sure.

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 a pull request may close this issue.

2 participants