You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
saphira said:
I've found a workaround, it works if I save the object first and then update it adding the dynamic attributes, but I still think that there's something odd with the behaviour described in the issue...
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)
System output
java
null
{code}
The text was updated successfully, but these errors were encountered: