benthosdev / benthos

Fancy stream processing made operationally mundane
https://www.benthos.dev
MIT License
7.68k stars 752 forks source link

MongoDB regression: ISODate fields get persisted as strings #2557

Open mihaitodor opened 2 weeks ago

mihaitodor commented 2 weeks ago

This issue was introduced in v4.26.0 (commit 9f692589b). Steps to reproduce:

> docker run --rm -p27017:27017 --name mongodb -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo
> docker exec -it mongodb bash
>> mongosh -u mongoadmin -p secret
>>> use food
>>> db.createCollection("fruits")
input:
  generate:
    mapping: |
      root.ts = "2024-04-29T12:34:05".ts_strptime("%Y-%m-%dT%T")
      root.name = "apple"
    count: 1

output:
  mongodb:
    url: mongodb://localhost:27017/?maxPoolSize=3
    username: mongoadmin
    password: secret
    database: food
    collection: fruits
    operation: insert-one
    write_concern:
      w: "majority"
      j: false
      w_timeout: 5s
    upsert: false
    document_map: |
      root = this

Run the above config with Benthos v4.25.0 and then with the current main branch (commit 51d971a) and then execute db.fruits.find() in mongosh. You'll notice that the ts field is different for the two entries.