We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've got a lot of MySQL tables with unsigned integer types (e.g. id INT(10) UNSIGNED).
id INT(10) UNSIGNED
I'm struggling to run queries against these with Diesel when their values exceed the positive i32 max value.
i32
E.g. using:
extern crate diesel; #[macro_use] extern crate diesel_codegen; use diesel::prelude::*; use diesel::mysql::MysqlConnection; use diesel::expression::sql; use diesel::types::Integer; #[derive(PartialEq, Debug, Queryable)] struct Thing { id: i32 } fn main() { let url = "mysql://user:pass@localhost/test" let conn = MysqlConnection::establish(&url).unwrap(); let query = sql::<Integer>("SELECT 4000000000"); query.load::<Thing>(&conn); }
results in a runtime error:
Err(DeserializationError(StringError("Numeric overflow/underflow occurred")))
which is expected, as it overflows i32, but is an acceptable u32 value.
u32
Changing my struct to:
struct Thing { id: u32 }
instead results in a compiler error:
the trait `diesel::types::FromSqlRow<diesel::types::Integer, _>` is not implemented for `(u32,)
Is this just unsupported by Diesel, or is there a different approach I should be taking for dealing with MySQL's unsigned integers?
The text was updated successfully, but these errors were encountered:
#912 reverted #782 because of u16, but maybe the other additions were valid?
u16
Sorry, something went wrong.
IIRC I was just straight up incorrect in #912, and we just need a PR that updates the code to not conflict with the latest master
Adding this to the milestone. The solution is literally just rebasing an old PR. The longer we wait, the harder that will be.
I'd like to take this one on as a first issue 😄
I attempted to rebase #782 with git, but I think it'll be easier to reapply it manually instead.
git
No branches or pull requests
I've got a lot of MySQL tables with unsigned integer types (e.g.
id INT(10) UNSIGNED
).I'm struggling to run queries against these with Diesel when their values exceed the positive
i32
max value.E.g. using:
results in a runtime error:
which is expected, as it overflows
i32
, but is an acceptableu32
value.Changing my struct to:
instead results in a compiler error:
Is this just unsupported by Diesel, or is there a different approach I should be taking for dealing with MySQL's unsigned integers?
The text was updated successfully, but these errors were encountered: