Allow u64 to be stored in an i64 #3080
christian-oudard
started this conversation in
Ideas
Replies: 1 comment
-
Diesel won't allow you using a That written there are multiple ways you can change that in your application:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am an engineer for MobileCoin. We are using SQLite, diesel, and rocket to build our wallet service.
https://github.com/mobilecoinofficial/full-service
In our database, we are storing amounts of MOB as u64 integers representing pico-MOB. For large values, we use SQLite negative values, which then get converted back after querying.
It would be very convenient to put some sort of filter at the database layer to convert i64 to u64 as they come out of the database. Unfortunately, I was unable to find any way that Diesel can do this conversion automatically, so we have been doing a lot of
as i64
andas u64
.The reason given in the compiler error why we can't have our model structs use u64 is because "the trait
diesel::Expression
is not implemented foru64
". Is there a way to implement this, so that it mimics our strategy of converting u64 to i64 during storage? Is this something that would be useful in the base library, or would it just be application-specific?Beta Was this translation helpful? Give feedback.
All reactions