Skip to content

Duplicate data when setData and ensureIndex #242

@ojovirtual

Description

@ojovirtual

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions