Skip to content

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

Open
@ngtuna

Description

@ngtuna

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions