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 up[E0277]: the trait bound `i32: diesel::types::FromSqlRow<diesel::types::Nullable<diesel::types::Integer>, diesel::pg::Pg>` is not satisfied #330
Comments
This comment has been minimized.
fuyingfuying
commented
May 15, 2016
|
I use ubuntu 15.10, and the version of rust is: fuying@fuying-linux:~/rustprojs/simtraining$ rustc --version
rustc 1.10.0-nightly (d91f8ab0f 2016-05-07)
fuying@fuying-linux:~/rustprojs/simtraining$ cargo --version
cargo 0.11.0-nightly (b304305 2016-05-06)
cargo.toml: [package]
name = "simtraining"
version = "0.1.0"
authors = ["fuying"]
[dependencies]
time = "^0.1"
rand = "^0.3"
libc = "^0.2"
mio = "^0.5"
serde = "^0.7.0"
serde_json = "^0.7.0"
serde_macros = "^0.7.0"
iron = "^0.3.0"
router = "^0.1.1"
diesel = { git = "https://github.com/diesel-rs/diesel.git" }
diesel_codegen = { git = "https://github.com/diesel-rs/diesel.git", default-features = false, features = ["nightly", "postgres"] }
dotenv = "^0.8.0"
dotenv_macros = "^0.8.0"
[dev-dependencies]
rand = "^0.3"
[target.x86_64-pc-windows-msvc.dependencies]
winapi = "^0.2"
ws2_32-sys = "^0.2"
[target.x86_64-pc-windows-gnu.dependencies]
winapi = "^0.2"
ws2_32-sys = "^0.2"
[target.i686-pc-windows-msvc.dependencies]
winapi = "^0.2"
ws2_32-sys = "^0.2"
[[example]]
name = "test-router"
path = "examples/testrouter.rs"
[[example]]
name = "test-create-user"
path = "examples/testcreateuser.rs"
|
This comment has been minimized.
|
This is correct. You cannot deserialize a column of type |
sgrif
closed this
May 15, 2016
This comment has been minimized.
fuyingfuying
commented
May 15, 2016
|
@sgrif |
This comment has been minimized.
fuyingfuying
commented
May 15, 2016
|
@sgrif #[derive(Queryable)] Does it correct? Because I am outside and can't test it. So if you are not busy, please help me. |
This comment has been minimized.
|
We don't really have support for embedded structs at the moment. When you're querying against two tables, you'd get back a use diesel::prelude::*;
use diesel::backend::Backend;
use diesel::types::{FromSqlRow + HasSqlType};
use diesel::row::Row;
use std::error::Error;
impl<ST, DB> FromSqlRow<ST, DB> for User where
DB: Backend + HasSqlType<ST>,
User: Queryable<ST, DB>,
<User as Queryable<ST, DB>>::Row: FromSqlRow<ST, DB>,
{
fn build_from_row<T: Row<DB>>(row: &mut T) -> Result<Self, Box<Error + Send + Sync>> {
let row = try!(<<User as Queryable<ST, DB>>::Row as FromSqlRow<ST, DB>>::build_from_row(row));
Ok(User::build(row))
}
}Note: Haven't tried that exact code, that's just from memory of what it'd roughly look like. We don't support the JSON type yet, but it's on the radar for something we'd like to support. #44 is the tracking issue, and I've mentioned how you could use it today in your app if needed in the comments there. |
This comment has been minimized.
fuyingfuying
commented
May 15, 2016
|
@sgrif |
1 similar comment
This comment has been minimized.
This comment has been minimized.
fuyingfuying
commented
May 15, 2016
|
@sgrif |
This comment has been minimized.
tmahmood
commented
Jul 22, 2017
|
Just a note, I faced similar issue. it's important that after you've made changes to the migration, run
From my limited understanding, I assume the custom code generator does not update the generated code and uses the old database definition, So we need to clean the generated code I am sorry, for least clear explanation as I'm sleepy and just figured out the problem. I hope it helps someone. |
This comment has been minimized.
theredfish
commented
Sep 3, 2017
•
|
@tmahmood thank you :) your solution solved my issue |
fuyingfuying commentedMay 15, 2016
Hello, when I try to use diesel to build my first orm, and error is come. My way is exactly same to your getting-start doc.
up.sql:
down.sql:
.env:
and the command
diesel migration redohas been executed successfully :fuying@fuying-linux:~/rustprojs/simtraining$ diesel migration redo Rolling back migration 20160514210851 Running migration 20160514210851lib.rs:
schema.rs:
user.rs: