Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upsert doesn't work well with query where value is []byte format #377

Open
ngtuna opened this issue Sep 26, 2019 · 0 comments
Open

Upsert doesn't work well with query where value is []byte format #377

ngtuna opened this issue Sep 26, 2019 · 0 comments

Comments

@ngtuna
Copy link

ngtuna commented Sep 26, 2019

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

v4.0.8

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

1.11.8

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

Ubuntu 18.04.1 amd64

What did you do?

Upsert doens't work well with query where value is []byte.

Example:
If I do an upsert with query := bson.M{"hash": hash} (hash [32]byte) in case of overwriting existing record. It says:

Error: E11000 duplicate key error collection: xxx.yyy index: hash_1 dup key: { : \"0xc023e09ff5f2d764fd08bfb92907d2d60cbc76d5acb8c808a26c9ed91278b489\" }"

Only work if I change hash to its string format like this: query := bson.M{"hash": hash.Hex()} - Hex() convert [32]byte to string.

Can you reproduce the issue on the latest development branch?

Haven't tried yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant