Skip to content

ReactiveMongoRepository save() does not return the persisted object #4847

@Poundex

Description

@Poundex

When calling the save() method I expect the returned object to be the object that was persisted in the database. However, I am finding that the returned object isn't the object as it was persisted, it is a copy of the object I passed in to be saved with its ID filled in. Things could happen in the database which mean this is not always the case (this is acknowledged by the documentation, which both specifies that the return value will be the object as persisted, and that this return value should be used for further processing as things may have changed in the database).

I ran into this issue because of the limited precision of Mongo's ISODateTime, although there are probably many other cases where this can happen.

Reproducer with failing test:
mongoentityissue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions