Skip to content
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

sqlite Integer columns associated with wrong rust data type. #2467

Closed
2 tasks done
quickdudley opened this issue Jul 27, 2020 · 1 comment
Closed
2 tasks done

sqlite Integer columns associated with wrong rust data type. #2467

quickdudley opened this issue Jul 27, 2020 · 1 comment

Comments

@quickdudley
Copy link

Setup

Versions

  • Rust:: 1.43.1
  • Diesel:: 1.4.1
  • Database:: sqlite 3.28.0
  • Operating System: Mac OS X

Feature Flags

  • diesel:

Problem Description

The diesel schema generator associates Integer columns with the diesel::sql_types::Integer type. The trait implementations for diesel::deserialize::FromSql all treat this as representing i32, but as per the sqlite documentation this column type can represent up to 64 bits.

Furthermore the FromSql instances for i64 are all for BigInt; which is not a valid column type in sqlite.

What are you trying to accomplish?

Derive Queryable instances for a struct which uses the same numeric type as the underlying database.

Are you seeing any additional errors?

The following compilation error occurs when attempting to use i64 numbers with the sqlite backend:

the trait `diesel::deserialize::FromSql<diesel::sql_types::Integer, diesel::sqlite::Sqlite>` is not implemented for `i64`

Steps to reproduce

In migration:

CREATE TABLE tasks(id INTEGER PRIMARY KEY);

In models.rs

#[derive(Queryable)]
pub struct Task {
    pub id: i64,
}

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
@weiznich
Copy link
Member

Duplicate of #852

@weiznich weiznich marked this as a duplicate of #852 Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants