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 $min and $max update operators #233

Merged
merged 5 commits into from
Mar 9, 2023

Conversation

tatu-at-datastax
Copy link
Contributor

What this PR does:

Adds $min and $max update operators

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

Checklist

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

@tatu-at-datastax tatu-at-datastax self-assigned this Mar 8, 2023
@tatu-at-datastax tatu-at-datastax changed the title (WIP) Implement $min and $max update operators Implement $min and $max update operators Mar 9, 2023
@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review March 9, 2023 01:50
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner March 9, 2023 01:50
* then recursively by value; and if first N fields the same, Object with more properties is sorted
* last.
*/
public class JsonNodeComparator implements Comparator<JsonNode> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. In memory sort made easy with this utility class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, was about to suggest just that, was thinking about it.

Choose a reason for hiding this comment

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

Cool. In memory sort made easy with this utility class.

Choose a reason for hiding this comment

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

Cool. In memory sort made easy with this utility class.

@tatu-at-datastax tatu-at-datastax merged commit 20f48ff into main Mar 9, 2023
@tatu-at-datastax tatu-at-datastax deleted the tatu/223-add-min-max branch March 9, 2023 16:20
"updateOne": {
"filter" : {"_id" : "update_doc_min"},
"update" : {"$min" : {
"min": 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to have an integration test that uses $min and $max with types that aren't numbers. For example, $min: { foo: 'bar' }. That should work given the JsonNodeComparatorTest.java tests, but I think it's worth checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I did add unit tests for wider range given they are more compact, but yeah I could/should add at least one cross-type, and one non-number IT operation.

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 $min and $max update operators
4 participants