Skip to content

GPMONGODB-20: .delete(flush:true) doesn't cascade from the owner in one-to-one relation #231

@graemerocher

Description

@graemerocher

Original Reporter: oct
Environment: Windows XP, Linux fedora 14 64bit, mongodb-M4, grails 1.3.7
Version: Not Specified
Migrated From: http://jira.grails.org/browse/GPMONGODB-20

owner.delete() doesn't delete it's dependant

{code}
//User.groovy
class User {
ObjectId id

String name
UserSettings settings
}
{code}

{code}
//UserSettings.groovy
class UserSettings {
ObjectId id

boolean someSetting = true

static belongsTo = [user:User]

static mapping = {
collection "user_settings"
}
}
{code}

// sample code
def u = new User(name:"Name1", settings:new UserSettings()).save(flush:true)

saves both domains fine, with bidirectional assoc and "foreign" DBRefs, but

u.delete(flush:true) leaves behind user_settings record, it doesn't cascade the delete.

{code}
// integration test code
void test_user_settings() {
def u = new User(name:"user2", settings:new UserSettings())
u.save(flush:true)

def found1 = User.findByName("user2")
assertNotNull found1

def found1a = UserSettings.findByUser(found1.id)
assertNotNull found1a

found1.delete(flush:true)

def found2 = User.findByName("user2")
assertNull found2

def found1b = UserSettings.findByUser(found1.id)
// THIS ONE FAILS
assertNull found1b
}
{code}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions