3. Verify the index name with the shell or Compass
##### Expected result
The index is named `field_2d`.
##### Actual result
The index is named `field_"2d"`.
![image](https://github.com/user-attachments/assets/f658eb09-26fd-42c2-aea9-ed9b1fdc8422)
The problem boils down to https://github.com/mongodb/mongo-rust-driver/blob/ef0893f77627a87b9eff7fbf4fd2059ea6b19211/src/index.rs#L38
where the `Bson` conversion of `v` to a string is always wrapped by `"`.
Since this logic is not public I had to reproduce it in my code and that's how I found the bug.
Versions/Environment
rustc 1.81.0 (eeb90cda1 2024-09-04)
Ubuntu 22.04.4 LTS on WSL/Windows 10 Pro 22H2
mongodb@3.1.0
andbson@2.13.0
MongoDB 8.0.1 Community
standalone
Describe the bug
When creating indexes with the
text
,2d
,2dsphere
orhashed
types the default index name generated by the driver does not follow the documentation.Steps to reproduce
[tokio::main]
async fn main() -> Result<()> { let client = Client::with_uri_str("mongodb://localhost:27017").await?; let db = client.database("test");
db.create_collection("test").await?;
let col = db.collection::("test");
col.create_index(IndexModel::builder().keys(doc! { "field": "2d" }).build()).await?;
Ok(()) }