Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.0.0.RC4
-
Fix Version/s: 1.1.0.GA
-
Labels:
-
Environment:Grails 2.0.1, Ubuntu 10.04 LTS 64 bit, MongoDB 2.0.3, Java 1.7.0_03
-
Testcase included:yes
Description
delete on a one to many relationship does not delete its dependents, when belongsTo is defined.
for instance, creating a User, which has many UserSettings:
class User {
ObjectId id
String name
static hasMany = [settings:UserSettings]
static constraints = {
}
}
class UserSettings {
ObjectId id
boolean someSetting = true
static belongsTo = [user:User]
}
Integration test: (UserSetting remains after User is deleted)
void test_user_settings() {
def u = new User(name:"user2")
def s = new UserSettings()
u.addToSettings(s)
u.save(flush:true)
def found1 = User.findByName("user2")
assertNotNull found1
def found1a = UserSettings.findByUser(found1)
assert found1.settings.size() == 1
found1.delete(flush:true)
def found2 = User.findByName("user2")
assertNull found2
def found1b = UserSettings.findByUser(found1)
// THIS ONE FAILS
assertNull found1b
}
I can also confirm this on OSX Mountain Lion w/ Grails 2.1.1, MongoDB 2.2.2, and MongoDB GORM 1.0.0.GA.
This seems to me like a greater than "Major" priority ticket.