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

BSON unmarshal unable to parse $date #404

Open
Tang8330 opened this issue Nov 18, 2022 · 0 comments
Open

BSON unmarshal unable to parse $date #404

Tang8330 opened this issue Nov 18, 2022 · 0 comments

Comments

@Tang8330
Copy link

Tang8330 commented Nov 18, 2022

We use the issue tracker to track bugs with mgo - if you have a usage question,
it's best to try Stack Overflow :)

Replace this text with your description, and please answer the questions below
before submitting your issue to help us out. Thanks!


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

db version v6.0.1
Build Info: {
    "version": "6.0.1",
    "gitVersion": "32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b",
    "modules": [],
    "allocator": "system",
    "environment": {
        "distarch": "aarch64",
        "target_arch": "aarch64"
    }
}

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

go1.19

What did you do?

If possible, provide a recipe for reproducing the error.
A runnable program is great and really helps!

var tsMap map[string]interface{}
	bsonData := []byte(`
{"_id": {"$numberLong": "10004"},"order_date": {"$date": 1456012800000},"purchaser_id": {"$numberLong": "1003"},"quantity": 1,"product_id": {"$numberLong": "107"}}

`)
err := bson.UnmarshalJSON(bsonData, &tsMap)

assert.NoError(p.T(), err)

Instead of it working, it returned an error, see:
err cannot parse date: "{\"$date\": 1456012800000}"

Can you reproduce the issue on the latest development branch?

@Tang8330 Tang8330 changed the title BSON unmarshal seems to have an issue BSON unmarshal unable to parse $date Nov 18, 2022
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