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

the trait bound `(schema::training_actions::columns::id, .......>` is not satisfied [E0277] #340

Closed
fuyingfuying opened this Issue May 21, 2016 · 8 comments

Comments

Projects
None yet
2 participants
@fuyingfuying

fuyingfuying commented May 21, 2016

@sgrif
Sorry to bother you again. I've confronted another E0277 Error.

fuying@fuying-linux:~/rustprojs/simtraining$ cargo build -j 8
   Compiling simtraining v0.1.0 (file:///home/fuying/rustprojs/simtraining)
<diesel macros>:18:64: 18:71 error: the trait bound `(schema::training_actions::columns::id, schema::training_actions::columns::sec, schema::training_actions::columns::nsec, schema::training_actions::columns::name, schema::training_actions::columns::session_id, schema::training_actions::columns::user_uid, schema::training_actions::columns::action_type, schema::training_actions::columns::dev_uid, schema::training_actions::columns::zhanwei_uid, schema::training_actions::columns::xitong_before, schema::training_actions::columns::xitong_after, schema::training_actions::columns::sec_duration, schema::training_actions::columns::nsec_duration, schema::training_actions::columns::score_op_order, schema::training_actions::columns::score_op_correct, schema::training_actions::columns::score_op_duration, schema::training_actions::columns::score): diesel::SelectableExpression<schema::training_actions::table, (diesel::types::Integer, diesel::types::BigInt, diesel::types::Integer, diesel::types::Text, diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::BigInt, diesel::types::Integer, diesel::types::Double, diesel::types::Double, diesel::types::Double, diesel::types::Double)>` is not satisfied [E0277]
<diesel macros>:18 :: FromClause { Identifier ( stringify ! ( $ name ) ) } } impl AsQuery for
                                                                                  ^~~~~~~
<diesel macros>:18:64: 18:71 note: in this expansion of table_body! (defined in <diesel macros>)
<diesel macros>:18:64: 18:71 note: in this expansion of table! (defined in <diesel macros>)
<diesel macros>:18:64: 18:71 note: in this expansion of infer_schema! (defined in src/lib.rs)
<diesel macros>:18:64: 18:71 help: run `rustc --explain E0277` to see a detailed explanation
<diesel macros>:18:64: 18:71 note: required because of the requirements on the impl of `diesel::query_builder::Query` for `diesel::query_builder::SelectStatement<(diesel::types::Integer, diesel::types::BigInt, diesel::types::Integer, diesel::types::Text, diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::BigInt, diesel::types::Integer, diesel::types::Double, diesel::types::Double, diesel::types::Double, diesel::types::Double), (schema::training_actions::columns::id, schema::training_actions::columns::sec, schema::training_actions::columns::nsec, schema::training_actions::columns::name, schema::training_actions::columns::session_id, schema::training_actions::columns::user_uid, schema::training_actions::columns::action_type, schema::training_actions::columns::dev_uid, schema::training_actions::columns::zhanwei_uid, schema::training_actions::columns::xitong_before, schema::training_actions::columns::xitong_after, schema::training_actions::columns::sec_duration, schema::training_actions::columns::nsec_duration, schema::training_actions::columns::score_op_order, schema::training_actions::columns::score_op_correct, schema::training_actions::columns::score_op_duration, schema::training_actions::columns::score), schema::training_actions::table>`
<diesel macros>:18:64: 18:71 note: required by `diesel::query_builder::AsQuery`
<diesel macros>:22:59: 22:64 error: the trait bound `(schema::training_actions::columns::id, schema::training_actions::columns::sec, schema::training_actions::columns::nsec, schema::training_actions::columns::name, schema::training_actions::columns::session_id, schema::training_actions::columns::user_uid, schema::training_actions::columns::action_type, schema::training_actions::columns::dev_uid, schema::training_actions::columns::zhanwei_uid, schema::training_actions::columns::xitong_before, schema::training_actions::columns::xitong_after, schema::training_actions::columns::sec_duration, schema::training_actions::columns::nsec_duration, schema::training_actions::columns::score_op_order, schema::training_actions::columns::score_op_correct, schema::training_actions::columns::score_op_duration, schema::training_actions::columns::score): diesel::SelectableExpression<schema::training_actions::table, _>` is not satisfied [E0277]
<diesel macros>:22 SelectStatement :: simple ( all_columns , self ) } } impl Table for table {
                                                                             ^~~~~
<diesel macros>:22:59: 22:64 note: in this expansion of table_body! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of table! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of infer_schema! (defined in src/lib.rs)
<diesel macros>:22:59: 22:64 help: run `rustc --explain E0277` to see a detailed explanation
<diesel macros>:22:59: 22:64 note: required by `diesel::Table`
<diesel macros>:22:59: 22:64 error: the trait bound `(schema::training_actions::columns::id, schema::training_actions::columns::sec, schema::training_actions::columns::nsec, schema::training_actions::columns::name, schema::training_actions::columns::session_id, schema::training_actions::columns::user_uid, schema::training_actions::columns::action_type, schema::training_actions::columns::dev_uid, schema::training_actions::columns::zhanwei_uid, schema::training_actions::columns::xitong_before, schema::training_actions::columns::xitong_after, schema::training_actions::columns::sec_duration, schema::training_actions::columns::nsec_duration, schema::training_actions::columns::score_op_order, schema::training_actions::columns::score_op_correct, schema::training_actions::columns::score_op_duration, schema::training_actions::columns::score): diesel::Expression` is not satisfied [E0277]
<diesel macros>:22 SelectStatement :: simple ( all_columns , self ) } } impl Table for table {
                                                                             ^~~~~
<diesel macros>:22:59: 22:64 note: in this expansion of table_body! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of table! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of infer_schema! (defined in src/lib.rs)
<diesel macros>:22:59: 22:64 help: run `rustc --explain E0277` to see a detailed explanation
<diesel macros>:22:59: 22:64 error: the trait bound `(schema::training_actions::columns::id, schema::training_actions::columns::sec, schema::training_actions::columns::nsec, schema::training_actions::columns::name, schema::training_actions::columns::session_id, schema::training_actions::columns::user_uid, schema::training_actions::columns::action_type, schema::training_actions::columns::dev_uid, schema::training_actions::columns::zhanwei_uid, schema::training_actions::columns::xitong_before, schema::training_actions::columns::xitong_after, schema::training_actions::columns::sec_duration, schema::training_actions::columns::nsec_duration, schema::training_actions::columns::score_op_order, schema::training_actions::columns::score_op_correct, schema::training_actions::columns::score_op_duration, schema::training_actions::columns::score): diesel::expression::NonAggregate` is not satisfied [E0277]
<diesel macros>:22 SelectStatement :: simple ( all_columns , self ) } } impl Table for table {
                                                                             ^~~~~
<diesel macros>:22:59: 22:64 note: in this expansion of table_body! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of table! (defined in <diesel macros>)
<diesel macros>:22:59: 22:64 note: in this expansion of infer_schema! (defined in src/lib.rs)
<diesel macros>:22:59: 22:64 help: run `rustc --explain E0277` to see a detailed explanation
<diesel macros>:22:59: 22:64 note: required by `diesel::Table`
src/trainingaction.rs:63:1: 63:35 error: the trait bound `diesel::pg::Pg: diesel::types::HasSqlType<(diesel::types::Integer, diesel::types::BigInt, diesel::types::Integer, diesel::types::Text, diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::BigInt, diesel::types::Integer, diesel::types::Double, diesel::types::Double, diesel::types::Double, diesel::types::Double)>` is not satisfied [E0277]
src/trainingaction.rs:63 #[changeset_for(training_actions)]
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trainingaction.rs:63:1: 63:35 note: in this expansion of #[changeset_for] (defined in src/trainingaction.rs)
src/trainingaction.rs:63:1: 63:35 help: run `rustc --explain E0277` to see a detailed explanation
src/trainingaction.rs:63:1: 63:35 help: the following implementations were found:
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::Bool>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::SmallInt>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::Integer>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::BigInt>>
src/trainingaction.rs:63:1: 63:35 help: and 11 others
src/trainingaction.rs:63:1: 63:35 note: required by `diesel::SaveChangesDsl`
src/trainingaction.rs:63:1: 63:35 error: the trait bound `diesel::pg::Pg: diesel::types::HasSqlType<(diesel::types::Integer, diesel::types::BigInt, diesel::types::Integer, diesel::types::Text, diesel::types::Integer, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::Text, diesel::types::BigInt, diesel::types::Integer, diesel::types::Double, diesel::types::Double, diesel::types::Double, diesel::types::Double)>` is not satisfied [E0277]
src/trainingaction.rs:63 #[changeset_for(training_actions)]
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/trainingaction.rs:63:1: 63:35 note: in this expansion of #[changeset_for] (defined in src/trainingaction.rs)
src/trainingaction.rs:63:1: 63:35 help: run `rustc --explain E0277` to see a detailed explanation
src/trainingaction.rs:63:1: 63:35 help: the following implementations were found:
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::Bool>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::SmallInt>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::Integer>>
src/trainingaction.rs:63:1: 63:35 help:   <diesel::pg::Pg as diesel::types::HasSqlType<diesel::types::BigInt>>
src/trainingaction.rs:63:1: 63:35 help: and 11 others
src/trainingaction.rs:63:1: 63:35 note: required by `diesel::Queryable`
error: aborting due to 6 previous errors
error: Could not compile `simtraining`.

To learn more, run the command again with --verbose.

up.sql:

CREATE TABLE training_actions (
  id SERIAL PRIMARY KEY,
  sec BIGINT NOT NULL,
  nsec INTEGER NOT NULL,
  name VARCHAR NOT NULL,
  session_id INTEGER NOT NULL,
  user_uid VARCHAR NOT NULL,
  action_type VARCHAR NOT NULL,
  dev_uid VARCHAR NOT NULL,
  zhanwei_uid VARCHAR NOT NULL,
  -- xitong_before VARCHAR NOT NULL,
  xitong_after VARCHAR NOT NULL,
  sec_duration BIGINT NOT NULL,
  nsec_duration INTEGER NOT NULL,
  score_op_order DOUBLE PRECISION NOT NULL,
  score_op_correct DOUBLE PRECISION NOT NULL,
  score_op_duration DOUBLE PRECISION NOT NULL,
  score DOUBLE PRECISION NOT NULL
);

trainingaction.rs:

use schema::*;
use diesel;
use diesel::prelude::*;
use diesel::pg::PgConnection;
#[insertable_into(training_actions)]
pub struct NewTrainingAction {
    pub sec: i64,
    pub nsec: i32,
    pub name: String,
    pub session_id: i32,
    pub user_uid: String,
    pub action_type: String,
    pub dev_uid: String,
    pub zhanwei_uid: String,
    // pub xitong_before: String,
    pub xitong_after: String,
    pub sec_duration: i64,
    pub nsec_duration: i32,
    pub score_op_order: f64,
    pub score_op_correct: f64,
    pub score_op_duration: f64,
    pub score: f64,
}
impl NewTrainingAction {
    pub fn new(sec: i64,
               nsec: i32,
               name: &str,
               session_id: i32,
               user_uid: &str,
               action_type: &str,
               dev_uid: &str,
               zhanwei_uid: &str,
            //    xitong_before: &str,
               xitong_after: &str,
               sec_duration: i64,
               nsec_duration: i32,
               score_op_order: f64,
               score_op_correct: f64,
               score_op_duration: f64,
               score: f64)
               -> NewTrainingAction {
        NewTrainingAction {
            sec: sec,
            nsec: nsec,
            name: name.to_string(),
            session_id: session_id,
            user_uid: user_uid.to_string(),
            action_type: action_type.to_string(),
            dev_uid: dev_uid.to_string(),
            zhanwei_uid: zhanwei_uid.to_string(),
            // xitong_before: xitong_before.to_string(),
            xitong_after: xitong_after.to_string(),
            sec_duration: sec_duration,
            nsec_duration: nsec_duration,
            score_op_order: score_op_order,
            score_op_correct: score_op_correct,
            score_op_duration: score_op_duration,
            score: score,
        }
    }
}
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, Queryable)]
#[changeset_for(training_actions)]
pub struct TrainingAction {
    pub id: i32,
    pub sec: i64,
    pub nsec: i32,
    pub name: String,
    pub session_id: i32,
    pub user_uid: String,
    pub action_type: String,
    pub dev_uid: String,
    pub zhanwei_uid: String,
    // pub xitong_before: String,
    pub xitong_after: String,
    pub sec_duration: i64,
    pub nsec_duration: i32,
    pub score_op_order: f64,
    pub score_op_correct: f64,
    pub score_op_duration: f64,
    pub score: f64,
}

impl TrainingAction {
    pub fn new(id: i32,
               sec: i64,
               nsec: i32,
               name: &str,
               session_id: i32,
               user_uid: &str,
               action_type: &str,
               dev_uid: &str,
               zhanwei_uid: &str,
            //    xitong_before: &str,
               xitong_after: &str,
               sec_duration: i64,
               nsec_duration: i32,
               score_op_order: f64,
               score_op_correct: f64,
               score_op_duration: f64,
               score: f64)
               -> TrainingAction {
        TrainingAction {
            id: id,
            sec: sec,
            nsec: nsec,
            name: name.to_string(),
            session_id: session_id,
            user_uid: user_uid.to_string(),
            action_type: action_type.to_string(),
            dev_uid: dev_uid.to_string(),
            zhanwei_uid: zhanwei_uid.to_string(),
            // xitong_before: xitong_before.to_string(),
            xitong_after: xitong_after.to_string(),
            sec_duration: sec_duration,
            nsec_duration: nsec_duration,
            score_op_order: score_op_order,
            score_op_correct: score_op_correct,
            score_op_duration: score_op_duration,
            score: score,
        }
    }
    pub fn create(conn: &PgConnection,
                  action: NewTrainingAction)
                  -> diesel::QueryResult<TrainingAction> {
        diesel::insert(&action).into(training_actions::table).get_result(conn)
    }
    pub fn show_all(conn: &PgConnection) -> diesel::QueryResult<Vec<TrainingAction>> {
        training_actions::table.load::<TrainingAction>(conn)
    }
    pub fn find_by_id(conn: &PgConnection, _id: i32) -> diesel::QueryResult<TrainingAction> {
        training_actions::table.find(_id).first::<TrainingAction>(conn)
    }
    pub fn update(conn: &PgConnection,
                  _id: i32,
                  data: &TrainingAction)
                  -> diesel::QueryResult<usize> {
        use ::schema::training_actions::dsl::*;
        diesel::update(training_actions.filter(id.eq(_id))).set(data).execute(conn)
    }
    pub fn delete(conn: &PgConnection, _id: i32) -> diesel::QueryResult<usize> {
        use ::schema::training_actions::dsl::*;
        diesel::delete(training_actions.filter(id.eq(_id))).execute(conn)
    }
}

If I remain the two files unchanged, there is no error. But if I uncomment the commented lines in the two files above, the error appears as the same as the output of bash displayed above.
So, does the total fields of struct which have the attribute of "changeset_for" must less than 17 ????
Please help me! All the night I am confronting this problem, and now it's 02:48. Thanks.

@sgrif

This comment has been minimized.

Member

sgrif commented May 21, 2016

Yes, by default the number of columns is capped at 16. You can increase it by adding features = ["large-tables"] to Travis.yml. The amount is lower by default to improve compile time.

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 21, 2016

@sgrif
Where is the file "Travis.yml" placed?? How can I find it.

@sgrif

This comment has been minimized.

Member

sgrif commented May 21, 2016

Sorry I meant Cargo.toml

On Sat, May 21, 2016, 2:53 PM fuying notifications@github.com wrote:

@sgrif https://github.com/sgrif
Where is the file "Travis.yml" placed?? How can I find it.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#340 (comment)

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 21, 2016

@sgrif Thanks for your help! It works. ^_^

@sgrif

This comment has been minimized.

Member

sgrif commented May 21, 2016

No problem. If you need more help in the future, consider asking in the gitter room instead of opening an issue.

@sgrif sgrif closed this May 21, 2016

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 21, 2016

@sgrif Where can i find the gitter room. Please give me an URL. Thanks!

@sgrif

This comment has been minimized.

Member

sgrif commented May 21, 2016

It's linked in the README. gitter.im/diesel-rs/diesel

On Sat, May 21, 2016, 3:23 PM fuying notifications@github.com wrote:

@sgrif https://github.com/sgrif Where can i find the gitter room.
Please give me an URL. Thanks!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#340 (comment)

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 21, 2016

@sgrif thanks, I've been in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment