-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use BsonReader & BsonWriter #2
Comments
Hello, |
Hello. I finished. |
@jershell The strict order of fields during deserialization is quite problematic :( For example, this class does not deserialize well: @Serializable
data class Friend(
var name: String?,
val address: String?,
@NonEncodeNull
@ContextualSerialization
val _id: ObjectId? = null) because in the bson coming from Mongo, the _id comes always first. But this one is ok (of course): data class Friend2(
@NonEncodeNull
@ContextualSerialization
val _id: ObjectId? = null,
var name: String?,
val address: String?) For the other fields, Mongo returns the fields in the insertion order, so it works. But imagine you insert a document using the shell in a different field order... The deserialization then is also broken. I would suggest a mechanism similar to the class of the mongo java driver org.bson.codecs.pojo.PojoCodecImpl:
|
@zigzago |
Thank you! It works fine as you can see: https://github.com/Litote/kmongo/compare/serialization?expand=1 I hit several other issues: #3 #4 #5, the polymorphic one is the biggest - if you fix #3, I think I will be able to release a first version :) |
Hello,
Trying to implement a first version of org.bson.codecs.Codec ( Litote/kmongo@8b03c13#diff-43a261a5b319c5b393c2428d036ce9f4R39 ), I hit a first issue.
encode & decode methods of Codec use BsonWriter & BsonReader but kbson takes BsonDocumentWriter & BsonDocument
Is it doable to change Encoder and Decoder input type?
Thank you
The text was updated successfully, but these errors were encountered: