globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 231 forks source link

Collection.EnsureIndex creates a undesired index name #340

Closed gnixuygnahz closed 5 years ago

gnixuygnahz commented 5 years ago

What version of MongoDB are you using (mongod --version)?

github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8

What version of Go are you using (go version)?

go version go1.11.4 windows/amd64

What operating system and processor architecture are you using (go env)?

windows10   ,  no

What did you do?

when i run this:

    index := mgo.Index{
        Name:       "objectId_1",
        Key:        ["objectId"],
        Unique:     true,
        Background: true,
        Sparse:     sparse,
    }
    err := db.C(tb).EnsureIndex(index)

it created a index naming "uqx_name"

Can you reproduce the issue on the latest development branch?

yes

domodwyer commented 5 years ago

Hi @gnixuygnahz

I'm going to close this as I'm unable to reproduce - happy to reopen if you have a runnable example though!

Dom