Diesel: he trait `diesel::Expression` is not implemented for `i64`

Created on 3 Feb 2021  路  7Comments  路  Source: diesel-rs/diesel

hi!

i am testing rockets for testing web login. when i run build , i got this error.

-my code

https://github.com/puffanddmx/rust_webserver/blob/master/src/model.rs#L3-L15

https://github.com/puffanddmx/rust_webserver/blob/master/Cargo.toml#L13

-error
src/model.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait diesel::Expression is not implemented for i64
|
= note: required because of the requirements on the impl of AsExpression<diesel::sql_types::Unsigned<diesel::sql_types::BigInt>> for i64
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound i64: diesel::Expression is not satisfied
--> src/model.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait diesel::Expression is not implemented for i64
|
= note: required because of the requirements on the impl of diesel::Expression for &'insert i64
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound i64: diesel::Expression is not satisfied
--> src/model.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait diesel::Expression is not implemented for i64
|
= note: required because of the requirements on the impl of diesel::Expression for &i64
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0277.
error: could not compile hello-rocket

-->

bug

All 7 comments

Closed as this does not use our issue template, which is mandatory. Additionally this is a duplicate of existing "issues".

That's cool, but it's now ranking high on google and I am left with having to ask here how to solve it :/
The feature "numeric" does not help

@MightyPork That's not the right place to ask such questions. Our issue tracker is for tracking bugs for our contributors not for providing support for our users. We have other places for such questions, please use them. Otherwise I do not really care if this is ranked high on google or somewhere else. That's no reason to not respect our rules.

@weiznich I don't understand why you are so angry, I just asked a question. You could have given me a short answer or linked some related issue, instead you told me exactly nothing.

For future users who hit this issue, I found the following:

As I understand it, sqlite supports i64 just fine, but does not support u64. The Sqlite backend in this crate is hard-wired to use i32 (https://github.com/diesel-rs/diesel/issues/1116) . I believe it can be worked around by using BigInt or a custom type wrapper. For now I switched my tables to use i32, as it was the easiest fix.

from the sqlite documentation (https://www.sqlite.org/datatype3.html):

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
... If the TEXT value is a well-formed integer literal that is too large to fit in a 64-bit signed integer, it is converted to REAL.

@MightyPork Again: This is not the right place for such comments. Please move them somewhere else.

Jesus, why are you like this? If someone finds this on google, they want to solve their problem, not read your tirade about people not using gitter.

I gave the answer. Please.

@MightyPork Again that's not the right place for such discussions. It's up to us maintainers to decide what we accept in our issue tracker and what does not belong here, not to same obscure google algorithm that decided that this shows up high in their results.
Also if you don't want to use gitter there are other options listed in our documentation.

Was this page helpful?
1 / 5 - 1 ratings