thedodd / wither

An ODM for MongoDB built on the official MongoDB Rust driver.
https://docs.rs/wither
Other
325 stars 40 forks source link

Model::sync is too naive. Needs to deep diff indices. #30

Closed thedodd closed 4 years ago

thedodd commented 5 years ago

According to the MongoDB docs:

To add or change index options other than collation, you must drop the index using the dropIndex() method and issue another db.collection.createIndex() operation with the new options.

Currently, Model::sync only diffs the keys of the index itself, but does not take into account the possibility that the options of the index may have changed. It definitely should take this into account and drop an index first if needed.

The code resides in wither::model::sync_model_indexes. A private function of the module which is called from Model::sync.

thedodd commented 5 years ago

Unblocked by mongodb-labs/mongo-rust-driver-prototype#299