Skip to content

GPMONGODB-67: Setting object to null does not clear it out #241

@graemerocher

Description

@graemerocher

Original Reporter: dfischer
Environment: MacOSX, Grails 1.3.7
Version: 1.0.0.M6
Migrated From: http://jira.grails.org/browse/GPMONGODB-67

{code}
class MyObject {
String name
MyOtherObject otherObject

static constraints = {
otherObject nullable: true
}
}
{code}

{code}
create() {
def myOtherObject = new MyOtherObject().save()
new MyObject(name: "testing", otherObject: myOtherObject).save()

// everything works as expected at this point
}

update() {
def myObj = MyObject.get(id)
myObj.otherObject.delete()
// id of otherObject still exists on myObj
myObj.otherObject = null
// id of otherObject still exists on myObj
myObj.save()
// id of otherObject still exists on myObj
}
{code}

The problem is that because the otherObject id still set in the MyObject document, this causes issues when the otherObject is accessed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions