Closed amber-m-o-r-e closed 4 years ago
@amber-m-o-r-e this appears to be an issue with the bson lib, as wither doesn't do anything with bson other than call its public interfaces and such.
I would recommend opening an issue in the bson repo. Feel free to reference back to this issue as well, of course. Sounds like you've got a pretty solid repo pattern, and you probably don't even need a database involved. You could setup a reproduction test case with the same struct you are using here, and then do some serialization / deserialization on the struct, then compare it against the output of the macro.
Keep me posted. Happy to help.
Hi thedodd,
Can you open a ticket as your self? as you are the owner of this repo and you can explain this problem properly in a ticket to bson guys.
@amber-m-o-r-e looks like someone beat you to it. Here is an issue in the bson crate describing the same problem: https://github.com/mongodb/bson-rust/issues/121
@amber-m-o-r-e given that this is a known issue originating from outside of this project, I'm going to close this issue. Let me know if you still need help resolving the issue.
I have the following code-
toml-
This code fails at ToDo::find and gives runtime error-
Err(BsonDe(DeserializationError { message: "invalid type: map, expected a formatted date and time string or a unix timestamp" }))
While inserting record it stores datetime value in string format in Mongo, but at update it saves update_at in perfect datetime in Mongo. But then while fetching it breaks, If you will not pass updated_at while updating record it works well without an error. If deleted_at will make it as optional as "pub deleted_at: Option\<DateTime\>" and pass None while inserting record then also at retrieve code fails with the same error.
Err(BsonDe(DeserializationError { message: "invalid type: map, expected a formatted date and time string or a unix timestamp" }))
Expected is to store perfectly DateTime marked data in datetime format at insertion as well as at update in Mongo. And If None is provided for optional then the program should tackle without failing while retrieving records.
Value of datetime in mongo while inserting is "2020-07-05T11:39:39.352802472Z" and after the update is ISODate("2020-07-05T11:39:39.360Z").