Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0-RC3
-
Fix Version/s: 2.0.1
-
Component/s: Persistence, Testing
-
Environment:Kubuntu linux, Intellij IDEA 10.5
-
Patch attached:Yes
-
Source ID:
Description
I use Joda Time plugin and it provides dateCreated and lastUpdated fields. In unit tests all instances that are saved for the second time in a test fail to pass NativeEntryEntityPersister#isDirty method. This is because they are instances of class org.grails.datastore.mapping.model.types.Custom and it's not included in this method. There is a simple fix, change this line:
if (prop instanceof Simple || prop instanceof Basic || prop instanceof ToOne ) {
if (!areEqual(oldValue, currentValue, key)) {
return true;
}
}
into:
if (prop instanceof Simple || prop instanceof Basic || prop instanceof ToOne || prop instanceof Custom ) {
if (!areEqual(oldValue, currentValue, key)) {
return true;
}
}
That fix will work for Joda-Time as it does not perform any type conversion when writing values to the simple datastore. However for some custom types the value of currentValue will actually be the stored serializable value whilst oldValue is the correct custom type & they will not be directly comparable.
I'm working on a patch right now.