DetermineIfFieldShouldBeSet

Posts   
 
    
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 09-Aug-2006 03:09:28   

I'm having a strange issue. When a certain entity property gets set to a certain value, I am setting it to Null with SetNewFieldValue(fieldindex, Nothing). If the CurrentValue of the field was already Nothing (Null), DetermineIfFieldShouldBeSet returns true, marking the entity as dirty even though there was no change in field values. It started out Null, and I set it to Null.

I can see how this makes sense in the case where the Entity was read straight from the database, and its Null field would get a default "real" CurrentValue set. In this case it makes complete sense the DetermineIfFieldShouldBeSet should return true if (!entityIsNew && fieldToSet.CurrentValue = Null). However, in my case, I have previously set the CurrentValue to Null with SetNewFieldValue(fieldindex, Nothing), so another call to SetNewFieldValue(fieldindex, Nothing) should not be marking the entity as dirty...

I hope this makes sense! confused

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 09-Aug-2006 09:54:42   

What's the llblgen pro version and runtime lib buildno you're using?

Is the entity new? If you've set the field to null already with SetNewFieldValue(index, null), didn't that action make the entity dirty already?

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 09-Aug-2006 21:58:55   

Otis wrote:

What's the llblgen pro version and runtime lib buildno you're using?

Is the entity new? If you've set the field to null already with SetNewFieldValue(index, null), didn't that action make the entity dirty already?

I am using 1.0.2005.1.

The entity is not new.

I looked into it further, and the problem is that when I set the value to null and save it to the database, the refetch does not set the CurrentValue or DBValue of the field. In ReadRowIntoFields, there is a foreach loop that goes through all the fields, setting them from the values[] array. My field gets its IsNull flag set, as it should, but fieldToSet.ForcedCurrentValueWrite is never called, and therefore the field never gets its CurrentValue or DBValue set from the results of the refetch. Because the CurrentValue never gets set to the "typeDefaultValue" it remains Null. It looks like there may be a "else" missing in...

if(fieldsPersistenceInfo[columnOrdinal].TypeConverterToUse!=null)

At this point the entity is flagged as not IsDirty (correctly) but the next time I set the value of this field value to Null, the DetermineIfFieldShouldBeSet returns "True" as the CurrentValue is STILL Null, causing the field to be set again, and the IsDirty flag to be set....

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 09-Aug-2006 23:19:34   

Please post the buildnr of the runtimes. right click ORMSupportclasses dll -> properties -> version tab in explorer. What you're seeing could be a bug that's been solved some times ago.

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 10-Aug-2006 00:51:23   

Otis wrote:

Please post the buildnr of the runtimes. right click ORMSupportclasses dll -> properties -> version tab in explorer. What you're seeing could be a bug that's been solved some times ago.

As usual Frans, you are right!


if(fieldsPersistenceInfo[columnOrdinal].TypeConverterToUse!=null)

was changed to


if(fieldsPersistenceInfo[columnOrdinal].TypeConverterToUse==null)

I didn't see it in your changelog, so I assumed it hadn't been fixed. But there it is, on 02-Jun! disappointed