apache / apache/grails-core

Grail 3.1 empty list is saving as null in mongodb

Open
#14,400 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-data-mongodb
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Hey, I am using grails 3.1. In this version, by default mongo is using MongoCodecSession but I have convertd it to MongoSession for some reason. Now when I am saving my domain instance in mongodb, it is saving empty list as null values which causes problem is $push. Below is my saving code
```
if(commit){
instance.save(flush: true)
instances.add(instance)
}
```
Any help?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Grails 3.1 save path using MongoSession rather than the default MongoCodecSession, with a domain instance containing an empty list. Inspect how instance.save(flush: true) persists empty lists and verify whether the stored value remains an empty list so subsequent $push operations work correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, mongodb
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.