[Extracted from a newsgroup message by Mark Smith]
I just finished about 1 day of struggle to find why
when I initialized attributes of a Part() the
initialization did not hold. Then I found the answer
which I post here.
To many this is obvious, but since it was a "gotcha"
for me I thought maybe this would help others.
When writing an attribute of a part to a stream, IO
(as designed) checks IsRequired and IsMandatory to see
if it needs to write the attribute's data.
I assume this is in order to save space in the BLOB
where needed.
however this causes the following scenario (I will
use a string value for the example):
In order not to have to open every part object and mark
every attribute "required" I changed the following code
in InstantPersistence.pas:
function TInstantAttribute.GetIsRequired: Boolean;
begin
// Commented out the IsRequired check
Result := Assigned(Metadata){ and Metadata.IsRequired};
end;
While this kills the IsRequired functionality, it it
more important IMHO that I can successfully initialize
my Part(s).
Logged In: YES
user_id=134829
The "required" functionality (which needs to be fixed since
it appears to be broken anyway) cannot be sacrificed, so I
don't think the fix is acceptable. I'd prefer to not check
IsRequired & such and always store all attributes regardless
of their default values.