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

Trait error when running MySQL example #826

Closed
HarmonEpsilon opened this Issue Mar 24, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@HarmonEpsilon

HarmonEpsilon commented Mar 24, 2017

Every time I try building the provided MySQL example, I encounter the following error:

error[E0277]: the trait bound `i32: diesel::types::FromSqlRow<diesel::types::BigInt, di
esel::mysql::Mysql>` is not satisfied
  --> src\lib.rs:38:28
   |
38 |     posts.order(id.desc()).first(conn).unwrap()
   |                            ^^^^^ the trait `diesel::types::FromSqlRow<diesel::type
s::BigInt, diesel::mysql::Mysql>` is not implemented for `i32`

I initially thought it was a bug with the nightly build from 2017-03-16, but when running on stable, I encounter the same error.
Info:
rustc 1.17.0-nightly
cargo 0.18.0-nightly
Diesel version 0.12.0

@ggrochow

This comment has been minimized.

Contributor

ggrochow commented Mar 24, 2017

It looks like your database table wasn't created with the correct id Integer type. Could you post your up.sql file from the migration that created the table?

I think the issue here is that your id field is a BigInt which converts into a rust i64 not i32

I was able to pass all the tests for this example locally (by cloning the repo, and running the test_all script)

@HarmonEpsilon

This comment has been minimized.

HarmonEpsilon commented Mar 24, 2017

Sure thing.

CREATE TABLE posts (
  id INTEGER PRIMARY KEY,
  title VARCHAR(100) NOT NULL,
  body TEXT NOT NULL,
  published BOOLEAN NOT NULL DEFAULT FALSE
);

I also cloned the repo and tried compiling Part 3 of the MySQL example and ran into the same problem.

@ggrochow

This comment has been minimized.

Contributor

ggrochow commented Mar 24, 2017

Could you try to diesel database reset that example database, and give it a run. ( still have a feeling that the table isn't setup properly, this should re-do it )

If that doesn't solve the issue, could you let us know the mysql version + OS you are using?
and if any of the other db-backends examples dont work?

@HarmonEpsilon

This comment has been minimized.

HarmonEpsilon commented Mar 24, 2017

There it goes. It's working now. Thanks.

@killercup killercup closed this Apr 5, 2017

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