-
Notifications
You must be signed in to change notification settings - Fork 196
Description
Original Reporter: saphira
Environment: Windows 7 64bits, Grails 2.2.1
Version: 1.3.0.GA
Migrated From: http://jira.grails.org/browse/GPMONGODB-306
When I try to store two Domain instances that only differ in the _id and a date property, the dynamic attribute is only stored in the first instance but not in the second one.
I've created a simple test with my domains to show the problem
{code}
void testAddDynamicProperty(){
setup:
def metadata = ["language":"java"]
Behaviour behaviour = Behaviour.list([max:1]).first()
User user = User.list([max:1]).first()
when:
UserBehaviour userBehaviour = new UserBehaviour(user:user,behaviour:behaviour,site:site,points:behaviour.points,date:new Date())
metadata.each{key,value->
userBehaviour."metadata${key}" = value
}
UserBehaviour userBehaviour2 = new UserBehaviour(user:user,behaviour:behaviour,site:site,points:behaviour.points,date:new Date())
metadata.each{key,value->
userBehaviour2."metadata${key}" = value
}
boolean valid1 = userBehaviour.save()
boolean valid2 = userBehaviour2.save()
then:
valid1 == true
valid2 == true
userBehaviour.metadatalanguage == "java"
userBehaviour2.metadatalanguage == "java"
}
{code}
And this is the result of executing that test
{code}
Condition not satisfied: userBehaviour2.metadatalanguage == "java" | | | | null false net.ds.gamigune.domain.activity.UserBehaviour(behaviour:net.ds.gamigune.domain.Behaviour(id:51d5196ac6c3c3a11664e0b9, namedId:b1, name:b1, hint:null, points:0, maxPerDay:0, maxPerSite:0, minInterval:0, active:true, hidden:false, icon:null, triggerEvents:[:]), site:net.ds.gamigune.domain.Site(id:51d5196ac6c3c3a11664e0af, privateKey:123, publicKey:456, name:site, description:null), points:0)
junit.framework.AssertionFailedError: Condition not satisfied:
userBehaviour2.metadatalanguage == "java"
| | |
| null false
net.ds.gamigune.domain.activity.UserBehaviour(behaviour:net.ds.gamigune.domain.Behaviour(id:51d5196ac6c3c3a11664e0b9, namedId:b1, name:b1, hint:null, points:0, maxPerDay:0, maxPerSite:0, minInterval:0, active:true, hidden:false, icon:null, triggerEvents:[:]), site:net.ds.gamigune.domain.Site(id:51d5196ac6c3c3a11664e0af, privateKey:123, publicKey:456, name:site, description:null), points:0)
at gamigune.test.integration.service.AchievementServiceSpec.testAddDynamicProperty(AchievementServiceSpec.groovy:524)
System output
java
null
{code}