Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Issue with persisting embedded null values #659

@kfujita-cohere

Description

@kfujita-cohere

Our team has faced issues with persisting null values on embedded fields. I did some debugging and found something that was a bit confusing.

The encodeEmbeddedUpdate method is only passing through the v param to encodeUpdate: https://github.com/grails/gorm-mongodb/blob/8.1.x/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/engine/codecs/PersistentEntityCodec.groovy#L439

This results in embedded being set to false: https://github.com/grails/gorm-mongodb/blob/8.1.x/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/engine/codecs/PersistentEntityCodec.groovy#L199

It then skips adding the null field to the unsets array, causing no change to the field in the database: https://github.com/grails/gorm-mongodb/blob/8.1.x/grails-datastore-gorm-mongodb/src/main/groovy/org/grails/datastore/mapping/mongo/engine/codecs/PersistentEntityCodec.groovy#L259-L261

Can someone explain this to me?

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