autoincrement=true
See original GitHub issueWhen using autoincrement on a primary key field
example:
@PrimaryKey (autoincrement=true) long id;
it appears the counter is getting reset when items are deleted. In other words, available ID’s lower than the MAX ID in a table are being re-used. It appears DB flow is managing its own internal autoincrement value?
In a scenario of insert record a, b, c. Their IDs become 1,2,3 respectively. If I remove item c and add item d I would expect item d’s ID to be 4, but its not, its 3.
Is this the desired behaviour?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
unable to create autoincrementing primary key with flask ...
If you are wanting an auto-incrementing id field for a composite key (ie. more than 1 db.Column(..) definition with primary_key=True , then ...
Read more >How to set a auto-increment value in SQLAlchemy?
I want to set a autoincrement value from 1000. How do I do it? postgresql · python · orm · sqlalchemy · Share....
Read more >Defining an Auto Increment Primary Key in PostgreSQL - Chartio
For a relational database like PostgreSQL, it could widely be considered a sin among developers not to include a primary key in every...
Read more >Setting the starting value of an autoincrement field?
autoincrement = True, autoincrementstart = 10000) ... I'm learning that the autoincrement support across databases is a bit
Read more >AutoIncrement Property - Business Central - Microsoft Learn
True if the field value is automatically incremented; otherwise, false. The default value is false. Note. If you want to manually assign a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is an example of the class. Appreciate you looking into this…
To remove (delete) I just call
someInstance.delete();
If I remove all items in the table, the next insert starts with an ID of 0.
`package com.fish4fun.myapp.models;
import android.util.Log;
import com.raizlabs.android.dbflow.annotation.Column; import com.raizlabs.android.dbflow.annotation.ModelContainer; import com.raizlabs.android.dbflow.annotation.PrimaryKey; import com.raizlabs.android.dbflow.annotation.Table; import com.raizlabs.android.dbflow.structure.BaseModel;
import java.io.File;
@ModelContainer @Table(database = MyAppDatabase.class) public class SomeEntity extends BaseModel {
more getters and setters… }`
in
develop