Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upExamine our compiler errors, and see if we can improve them #151
Comments
This comment has been minimized.
|
Yes, please. Here is one that drives me crazy:
Model:
I looked at the tests and the code looks alright. But I'm also just getting started with Diesel, so maybe I got something fundamentally wrong.. |
This comment has been minimized.
|
Switch the order of the columns on your model. It's trying to load the ID On Fri, Mar 18, 2016, 6:25 PM Jakob Gillich notifications@github.com
|
This comment has been minimized.
|
Oh wow, the order matters? I had no idea haha, thanks! |
This comment has been minimized.
|
For now, yes. We use indexed access instead of named access for performance On Fri, Mar 18, 2016, 6:30 PM Jakob Gillich notifications@github.com
|
This comment has been minimized.
TheNeikos
commented
Aug 24, 2016
I believe this is something that could be adressed (for now) in the guide as I just stumbled onto this as well, and it cost me around more than hour trying to find out what is going on. |
This comment has been minimized.
|
This is one you helped me with in gitter.im
adding an explicit type annotation to res solved this issue
|
This comment has been minimized.
flybayer
commented
May 5, 2017
|
I'm stuck with the below error and can't figure it out. The postgres table was created with Rails which manages the schema. Error(reformatted a bit for readability)
Model#[derive(Queryable)]
pub struct EndDevice {
pub id: i64,
pub eui: Option<String>,
pub app_key: Option<String>,
pub created_at: types::Timestamp,
pub updated_at: types::Timestamp,
}My DB Table
|
This comment has been minimized.
|
You shouldn't use |
This comment has been minimized.
flybayer
commented
May 8, 2017
|
Thank you @Eijebong, I got it working! For reference, this is working: use chrono::prelude::*;
#[derive(Queryable, Debug)]
pub struct EndDevice {
pub id: i64,
pub eui: Option<String>,
pub app_key: Option<String>,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
} |
This comment has been minimized.
|
Just saw rust-lang/rust#43000 and remembered this issue. I think we talked about it, but I'm not sure what the result was: Did we ever try something like the following? #![cfg_attr(feature="unstable", feature(on_unimplemented))]
#[cfg_attr(feature="unstable", rustc_on_unimplemented("To query … you can find more info in our docs at http://diesel.rs/")]
pub trait FromSql // … |
This comment has been minimized.
|
Yes. It doesn't give us the diagnostics we'd need in most cases, and rust-lang/rust#28894 and rust-lang/rust#33094 generally cause our error message to never show up anyway |
sgrif commentedJan 30, 2016
At times, our compiler errors just flat out suck. While in this issue I will list several cases that I've specifically noticed are frequently problematic or have personally encountered, it should not be treated as exhaustive. If you've ever received a non-helpful compiler message from this lib, please comment with details. I do not think we will be able to fix all of them, but we should try to improve this issue before 1.0.
Truly "fixing" this will probably require significantly more control over the "trait not implemented" error, both on the trait itself (e.g. we can give a much better message for any case where
SelectableExpressionisn't implemented), and also at the function level (e.g. whenfinddoesn't work, we can probably be more specific, even though none of the traits failing are specific to find).As we attempt to make sure we create good error messages, we should update our
compile-failsuite to be significantly more specific about the error messages we generate. While that will make those tests much more brittle, I'd rather have to update them frequently (and thus ensure that the new error message is still reasonable), than accidentally start generating a nonsense error for a common case.Problem Cases
Recommending
Expressioninstead ofAsExpressionA consistent source of confusion is
rustc's recommendation to implementExpression,NonAggregate, andQueryFragment, when the missing piece is actuallyAsExpression. Ultimately this is due to rust-lang/rust#28894. If we can't fix that issue in the language, we should probably just remove that blanket impl and brute force it instead (I'm honestly surprised the coherence rules haven't forced this already, I think this is the only blanket impl that's survived).Some types are too long to ever appear in error messages
Another case that we should look for is any case where
SelectStatementorFilterQuerySourceend up in the final error message. It doesn't matter what trait is missing, the error messageSelectStatement<(type1, type2, type3, 10moretypes), (col1, col2, col3, 10morecolumns), InnerJoinQuerySource<left_table, right_table>, NoWhereClause, NoOrderClause, NoLimitClause, NoOffsetClause> does not implement AsQuerywill always be too noisy to be helpful. That specific error is actually one of the simpler cases, and even with that exact case, every type would have the fully qualified path, and be repeated 3 times (saying it looked atSelectStatement,&SelectStatement, and&mut SelectStatement). It's not uncommon for that kind of error message to take up the entire terminal window.