Skip to content

bug: IndexedMap's clear function doesn't clean indexes. #117

@bullet-tooth

Description

@bullet-tooth

Description:

I recently found an unexpected behaviour that removing all entities from the IndexedMap does nothing with the indexes, so the indexes start to reference non-existing data in the main collection and lead to StdError::msg("pk not found") error when searching some data by index after deletions.

In my understanding, the clear function should remove the data completely to keep the underlying storage in a consistent state.

Also, it is worth noting that there is no convenient method to clear data from the indexes separately.

Please see the PR with unit test (red now) that reproduces the issue: #116

Steps to reproduce:

  • Create IndexedMap
  • Add a few entities
  • Call clear
  • Verify a count of entities in the defined indexes

Actual Behaviour: Each index returns all previously saved entities defined by inthe dex.

Expected Behaviour: Each index should be empty.

Question:

If you find it important to fix, I could work with the pull request on the implementation.

UPD: PR is ready for review

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions