-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Problem with big UInt64 values #389
Comments
BSON doesn't support It's same problem in MongoDB. Take a look here: |
Sorry, I mean the BsonMapper.Serialize and BsonMapper.Deserialize, convert to/from .net type UInt64.
|
No need to use BitConverter. Actually to convert between Int64 and UInt64 you can just cast within unchecked( ) like this: unchecked((UInt64)((Int64)value.RawValue)) This will cast -1 to UInt64.MaxValue without throwing IntegerOverflowException. |
@henon, so, it´s safe to put here? https://github.com/mbdavid/LiteDB/blob/master/LiteDB/Mapper/BsonMapper.Deserialize.cs#L110 |
I guess so. You could do UInt32 and UInt64 conversion before that line. Actually, instead of converting to and from BSON supported types I'd vote for extending BSON and save all basic .Net types without any conversion allowing queries with UInt64 that are not saved as potentially negative Int64, but that is another story for another thread. |
Using big UInt64 values like UInt64.MaxValue can not be converter to/from bson Int64, an overflow exception occurs.
Possible solution is on serialization:
deserialization:
The text was updated successfully, but these errors were encountered: