Replies: 6 comments 3 replies
-
Note also the open bson-ruby PR: mongodb/bson-ruby#238 Unfortunately it seems that referinging PRs from discussions doesn't add a reference back to discussion from the PR. |
Beta Was this translation helpful? Give feedback.
-
@p-mongo my vote is #1. Let's keep it simple and have this work "out-of-the-box" for first-time Mongoid / Mongo Ruby users using Rails and other serialization libraries which also rely on |
Beta Was this translation helpful? Give feedback.
-
I also vote for #1.
|
Beta Was this translation helpful? Give feedback.
-
@p-mongo are you in agreement? I think the only remaining decision is how we handle BSON types which do not cleanly map to JSON. Specifically these types:
Here are our choices: (a) alias Taking
My vote here is (a) to alias these to |
Beta Was this translation helpful? Give feedback.
-
Hi @johnnyshields, we discussed the situation with @comandeo and our current thinking is as follows:
Does this sound agreeable to you? |
Beta Was this translation helpful? Give feedback.
-
@p-mongo @comandeo I've implemented the correct #as_json and #as_extended_json logic for all classes in 4 separate PRs. Each PR can be merged individually. Ready for your review. |
Beta Was this translation helpful? Give feedback.
-
In https://jira.mongodb.org/browse/MONGOID-5158 @johnnyshields requested changing BSON::ObjectId#as_json to return the hex-serialized ObjectId value as a string instead of the current
{"oid" => "..."}
syntax. I provided some feedback on that initial proposal in #5054, which outlines the current situation. In discussion with @comandeo we considered how to move forward with the change to ObjectId in particular (not yet discussing the other classes) and identified the following options:Have bson-ruby 5.0 return a simple string from ObjectId#as_json. This is a breaking change.
Remove ObjectId#as_json from bson-ruby altogether and provided it in a separate library. Technically the required functionality in bson-ruby is serialization to extended JSON, which is now done via ObjectId#as_extended_json, and ObjectId#as_json is possibly not needed for bson-ruby itself at all.
Because bson-ruby does provide functionality for integrating with ActiveSupport (such as handling of TimeWithZone objects), another option is to leave ObjectId#as_json in bson-ruby but make it a separate component that is requred from
bson/active_support
such that applications can opt into it if needed.With either of the last two options, two implementations of ObjectId#as_json may be provided in the same library version (be that bson-ruby or a new library): the existing one that returns extended JSON
oid
syntax, and the proposed new one that returns a simple string. This way applications can be configured at runtime with the desired implementation. This would hopefully make upgrades simpler as applications would be able to move to the new version of bson-ruby without needing changes to account for the ObjectId#as_json behavior.@johnnyshields would love to hear your thoughts on the above.
Beta Was this translation helpful? Give feedback.
All reactions