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

Duplicate data when setData and ensureIndex #242

Open
ojovirtual opened this issue Apr 4, 2018 · 1 comment
Open

Duplicate data when setData and ensureIndex #242

ojovirtual opened this issue Apr 4, 2018 · 1 comment

Comments

@ojovirtual
Copy link

ojovirtual commented Apr 4, 2018

Hi there,
I've found what I think is a bug. In summary, when using setData to set the collection contents and there is an index, lookups using this index can return duplicate data.

var testCol=db.collection('testCol');
testCol.setData([{"a":1,"b":1},{"a":2,"b":2},{"a":3,"b":3}]);
testCol.find();
//returns 3 items, that's OK
testCol.find({"a":2});
//returns 1 item, that's also OK
testCol.ensureIndex({"a":1});
testCol.setData([{"a":1,"b":4},{"a":2,"b":5},{"a":3,"b":6}]);
testCol.find();
//returns 3 items, the last setData replaced old data
testCol.find({"a":2});
//returns 2 items, [ {"a":2,"b":2} , {"a":2,"b":5} ]  , that's not OK

As a workaround, using truncate before setData works fine.
Probably setData is not updating the indexes.

Edit:
Forgot to say, I'm using Forerunner 2.0.22.

@Irrelon
Copy link
Owner

Irrelon commented Apr 12, 2018

Thanks for this, have confirmed the bug, will push a fix shortly...

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

2 participants