valentingoebel opened a new issue, #14388: URL: https://github.com/apache/grails-core/issues/14388
Here is an example project: https://github.com/valentingoebel/grails-dirtycheckingbug/ application.yml requires following env variables so make sure you fill them. ```yaml grails: mongodb: host: ${MONGODB_HOST} port: 27017 username: ${MONGODB_USER} password: ${MONGODB_PASS} databaseName: grailsdirtycheckingbug ``` Here is a summary of the code: ```groovy class DBList { static constraints = { } List<DBListEntry> entries = [] static embedded = ['entries'] static hasMany = [ entries: DBListEntry ] } class DBListEntry { String value static constraints = { } } class DBListController { def index(Integer max) { def dblist = DBList.list()[0] dblist.entries.each { it -> it.value = it.value + "1" render "DBListEntry: This should be dirty but it isn't: ${it.listDirtyPropertyNames()}<br>" } render "DBList: This is not dirty (optional bug): ${dblist.listDirtyPropertyNames()}<br><br>" dblist.entries.each { it -> it.trackChanges() } dblist.entries.each { it -> it.value = it.value + "2" render "DBListEntry: It works!: ${it.listDirtyPropertyNames()}<br>" } render "DBList: This is not dirty (optional bug): ${dblist.listDirtyPropertyNames()}<br><br>" render "Output: ${dblist.entries*.value}<br>" } } ``` 1. Calling `trackChanges()` on each entity inside the embedded list results in the desired outcome. I am already using this workaround in my projects but it required substantial changes in my code because using databinding in controller parameters like `def show(DBList list)` will fill each field before you even get an opportunity to call trackChanges(). 2. Even with `trackChanges()` there is still the issue that the list itself does not get marked as dirty. This is fine in the non embedded case because changing an entity would mark all its associated entities dirty which is certainly not what we want but for embedded entities it could make sense because an embedded entity is always contained inside a parent entity. Therefore changing the child could be interpreted as a change in the parent. I only need the first bug fixed because it prevents me from using databinding in controller parameters. The second one is up for discussion and can be rejected if it doesn't make sense. Marking a list dirty when at least one of its elements has changed is very easy so I'm not really insisting on that change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
