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

BUG autoId & Shrink #899

Closed
nrudkovskiy opened this issue Feb 10, 2018 · 4 comments
Closed

BUG autoId & Shrink #899

nrudkovskiy opened this issue Feb 10, 2018 · 4 comments

Comments

@nrudkovskiy
Copy link

Hi mbdavid, I reproduce bug with auto id and Shrink.
public class EntityInt { public int Id {get; set;} public string Name {get; set;} }
;
File.Delete("E:\Temp\Test.db");

var db = new LiteDatabase("E:\\Temp\\Test.db")
var col = db.GetCollection<EntityInt>("col1");
for(int i =0; i<50; i++)
    col.Upsert(new EntityInt {Name = i.ToString()});

for(int i =0; i<10; i++)
    col.Delete(i);

db.Shrink();

for (int i = 0; i < 5; i++)
    col.Upsert(new EntityInt { Name = i.ToString() }); //Cannot insert duplicate key in unique index '_id'. The duplicate value is '42'.

`

@mbdavid mbdavid added the bug label Feb 10, 2018
@mbdavid
Copy link
Collaborator

mbdavid commented Feb 10, 2018

Hi @nrudkovskiy, thanks! Yes, now I got why this occurs in some cases.. but no one tell me about shrink.. I forgot to override Sequence counter when shrink. I'm fixing...

Plans to release new version 4.1.2 in this carnival holiday.

mbdavid added a commit that referenced this issue Feb 10, 2018
@mbdavid
Copy link
Collaborator

mbdavid commented Feb 10, 2018

Fixed. Just update sequence number :) Thanks!

@nrudkovskiy
Copy link
Author

nrudkovskiy commented Feb 10, 2018 via email

@mukeshpiplai
Copy link

mukeshpiplai commented Dec 4, 2020

Hi @mbdavid, I am facing the same issue in LiteDB Studio (v1.0.2.0). During opening a LiteDB database, it says Cannot Insert duplicate key in unique index '_id'. The duplicate value is '{"guide":961................ I want to shrink/reduce my LiteDB database generated in open bullet
litedbIssue

This is my database file:
mydb.db
.

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

No branches or pull requests

4 participants