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

Another AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1) #356

Closed
dmilicic opened this issue Aug 11, 2015 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@dmilicic
Copy link

I get the issue using this code:

@Table(databaseName = Database.NAME, allFields = true)
public class Activity extends BaseModel {

    @PrimaryKey(autoincrement = true)
    int id;

    Date date;

    int steps;

    double calories;
}

This is the exception:

android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE IF NOT EXISTS `Activity`(`id` INTEGER(0) PRIMARY KEY AUTOINCREMENT, `date` INTEGER(0), `steps` INTEGER(0), `calories` REAL(0));

I believe this is very similar to this issue: #288

The id should probably be INTEGER instead of INTEGER(0) as in the issue above.

This code works correctly so I think it should be an issue with an allFields variable:

@Table(databaseName = Database.NAME)
public class Activity extends BaseModel {

    @Column
    @PrimaryKey(autoincrement = true)
    int id;

    @Column
    Date date;

    @Column
    int steps;

    @Column
    double calories;
}
@mesterj
Copy link

mesterj commented Aug 12, 2015

I think this is not good idea to name your class Activity. And why don't use long id? This is the suggested way.

@dmilicic
Copy link
Author

This was a demo app and I did use id as long but the same issue appeared, as in the issue I linked to. I forgot to point that out :)

@agrosner agrosner added the bug label Aug 20, 2015
@agrosner agrosner modified the milestones: 2.3.1, 2.3.0 Aug 20, 2015
@agrosner agrosner self-assigned this Aug 20, 2015
@agrosner
Copy link
Owner

Been fixed in develop branch

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

3 participants