-
Notifications
You must be signed in to change notification settings - Fork 97
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
Improve ObjectId support #41
Conversation
@johnoliver Isn't this already effectively done? (Alternative implementation) |
assertEquals(id, ((JsonObject) id_value).getString("$oid")); | ||
} else { | ||
assertEquals(id, (String) id_value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could extract this piece of assert code? It's mostly repeated above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can wrap it to a method together with other comments if any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got no further code comments, good quality patch :-) - but @johnoliver
will need to check to make sure this isn't an alternative implementation of
a previously accepted patch.
On Monday, 14 September 2015, meggarr notifications@github.com wrote:
In
vertx-mongo-client/src/test/java/io/vertx/ext/mongo/MongoClientTestBase.java
#41 (comment)
:@@ -691,7 +696,12 @@ public void testReplaceUpsert2() {
mongoClient.find(collection, new JsonObject(), onSuccess(list -> {
assertNotNull(list);
assertEquals(1, list.size());
assertEquals(id, list.get(0).getString("_id"));
Object id_value = list.get(0).getValue("_id");
if (id_value instanceof JsonObject) {
assertEquals(id, ((JsonObject) id_value).getString("$oid"));
} else {
assertEquals(id, (String) id_value);
}
Yes, I can wrap it to a method together with other comments if any.
—
Reply to this email directly or view it on GitHub
https://github.com/vert-x3/vertx-mongo-client/pull/41/files#r39390711.
Cheers, Martijn (Sent from Gmail Mobile)
The main purpose of the change is in two aspects
|
I want to merge this as I think it is needed, only problem is this does change the current API slightly. Currently a document will be returned as: {"_id":"5603e9ef6edd3843424db95b",...} With this patch it will be: I think this is an improvement, I am just a bit worried about breaking API compatibility here. @karianna are we able to break this given the next release is a 3.1.0? Given _id support was only added after the last release, I am inclined to say yes. |
If we're following semantic versioning I'd say technically no (a breaking change should really force a major version number bump, i.e. 4.x). That said, we're pinned by the overall vertx release train version numbering so it kind of doesn't really matter! I'd say go for it and we'll make sure there's a serious warning label in the release notes. |
@johnoliver I've missed the last week or so's vertx traffic BTW, I assume 3.1.0 is still to go out yeah? |
3.1.0 is planned for next week (end of September). |
@meggarr Thank you for the contribution |
@johnoliver Glad to contribute my code. :) During experience of MongoClient of Vert.X, I agree with your concern about my patch changes the content - (ObjectId string is already translated to Json with |
I agree I think it would be a good idea to translate it back to a string when it is returned. |
I also think we need to go through all of the methods in |
@johnoliver - Can you split that into a separate issue? |
Improve the ObjectId support in read/write object id from JsonObject. Also it adds protection if the "_id" field provided is not a valid ObjectId string.