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

Allowing integer to map to i64 for sqlite #1116

Closed
Boscop opened this issue Aug 17, 2017 · 2 comments
Closed

Allowing integer to map to i64 for sqlite #1116

Boscop opened this issue Aug 17, 2017 · 2 comments
Labels

Comments

@Boscop
Copy link

Boscop commented Aug 17, 2017

When I use id integer not null primary key autoincrement in sqlite, I have to use i32 in Rust but I want to have i64 because I have a lot of records, but when I write id bigint not null primary key autoincrement I get:

error: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY

This is a syntactic limitation of sqlite but sqlite stores all integers as arbitrary precision anyway, so it would be possible for diesel to also allow mapping integer to i64.
It would be very useful!

Also, it doesn't let me use u64 for size_bytes unsigned bigint not null, only i64...

@sgrif
Copy link
Member

sgrif commented Aug 19, 2017

This has been raised before, and we decided to keep things as they are for reasons I laid out in #852 (comment). If you need i64 keys, you can use table! or diesel print-schema and specify that the id column is of type BigInt there, but I don't think we should change the behavior of schema inference for the reasons I laid out in the previous comment.

@WANG-lp
Copy link

WANG-lp commented Oct 22, 2020

@sgrif Very glad to see there is a correct method to use i64 for Sqlite.

I think #80 can be also solved this method.

Maybe we can collect similar questions and solutions to a separated Wiki page to help newcomers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants