From: <fas...@us...> - 2006-02-13 17:57:40
|
Revision: 588 Author: fastbike2 Date: 2006-02-13 09:57:13 -0800 (Mon, 13 Feb 2006) ViewCVS: http://svn.sourceforge.net/instantobjects?rev=588&view=rev Log Message: ----------- Fix for Bug 1375131: Evolving database with part attributes causes "Class Not Registered" error when object is retrieved. Modified Paths: -------------- trunk/Source/Core/InstantPersistence.pas Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2006-02-13 15:56:16 UTC (rev 587) +++ trunk/Source/Core/InstantPersistence.pas 2006-02-13 17:57:13 UTC (rev 588) @@ -14403,6 +14403,8 @@ procedure ReadPartAttribute; var Stream: TInstantStringStream; + LPartClassName: string; + LPartId: string; begin if AttributeMetadata.StorageKind = skExternal then begin @@ -14411,13 +14413,23 @@ // Must clear Value first to avoid leak for Refresh operation // as OldValue = NewValue. Value := nil; - Value := InstantFindClass(ReadStringField(DataSet, AFieldName + InstantClassFieldName)).Retrieve( - ReadStringField(DataSet, AFieldName + InstantIdFieldName), False, False, AObject.Connector); + LPartClassName := ReadStringField(DataSet, AFieldName + + InstantClassFieldName); + LPartId := ReadStringField(DataSet, AFieldName + + InstantIdFieldName); + // LPartClassName and LPartId will be empty if the attribute was + // added to a class with existing instances in the database. + if (LPartClassName = '') and (LPartId = '') then + (Attribute as TInstantPart).Reset + else + Value := InstantFindClass(LPartClassName).Retrieve(LPartId, + False, False, AObject.Connector); end; end else begin - Stream := TInstantStringStream.Create(ReadBlobField(DataSet, AFieldName)); + Stream := TInstantStringStream.Create(ReadBlobField(DataSet, + AFieldName)); try if Stream.Size = 0 then (Attribute as TInstantPart).Reset |