From: <wp...@us...> - 2009-12-22 19:11:53
|
Revision: 881 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=881&view=rev Author: wp2udk Date: 2009-12-22 19:11:42 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Two bug fixes: - The BDE Broker wasn't able to create SequenceNo without throwing an 'Invalid field size' BDE Exception. Don't know why this happened? The field size was 32. It works for other Integer types? Setting the field size to 0 fixes the problem. - TInstantAttributeType = atEnum was not supported by the Exposer. Attribute types of atEnum was treated as Strings. This attribute type is now treated as Integer. Modified Paths: -------------- trunk/Source/Brokers/BDE/InstantBDE.pas trunk/Source/Core/InstantPresentation.pas trunk/Source/Core/InstantRtti.pas Modified: trunk/Source/Brokers/BDE/InstantBDE.pas =================================================================== --- trunk/Source/Brokers/BDE/InstantBDE.pas 2009-12-21 09:13:48 UTC (rev 880) +++ trunk/Source/Brokers/BDE/InstantBDE.pas 2009-12-22 19:11:42 UTC (rev 881) @@ -410,6 +410,7 @@ I: Integer; Table: TTable; IndexName: string; + TmpSize: Integer; begin Table := TTable.Create(nil); try @@ -427,8 +428,17 @@ end; for I := 0 to Pred(FieldMetadatas.Count) do with FieldMetadatas[I] do - Table.FieldDefs.Add(Name, FieldTypes[DataType], Size, + begin + // Avoid 'Invalid field size' BDE Exception when creating + // SequenceNo. Don't know why it only happens for this dtInteger + // field? + if DataType = dtInteger then + TmpSize := 0 else + TmpSize := Size; + + Table.FieldDefs.Add(Name, FieldTypes[DataType], TmpSize, foRequired in Options); + end; end; Table.CreateTable; finally Modified: trunk/Source/Core/InstantPresentation.pas =================================================================== --- trunk/Source/Core/InstantPresentation.pas 2009-12-21 09:13:48 UTC (rev 880) +++ trunk/Source/Core/InstantPresentation.pas 2009-12-22 19:11:42 UTC (rev 881) @@ -2211,6 +2211,21 @@ Result := ftString; end; + function EnumerationToFieldType(const FieldName: string): TFieldType; + var + AttributeMetadata: TInstantAttributeMetadata; + begin + Result := ftString; + AttributeMetadata := FindAttributeMetadata(FieldName); + if Assigned(AttributeMetadata) then + case AttributeMetadata.AttributeType of + atEnum: + Result := ftInteger; + atBoolean: + Result := ftBoolean; + end; + end; + var FieldName: string; FieldType: TFieldType; @@ -2230,10 +2245,11 @@ Include(FieldAttribs, DB.faReadOnly); case TypeKind of tkEnumeration: - if PropInfo^.PropType^^.Name = 'Boolean' then + FieldType := EnumerationToFieldType(FieldName); +{ if PropInfo^.PropType^^.Name = 'Boolean' then FieldType := ftBoolean else - FieldType := ftString; + FieldType := ftString;} tkString, tkLString{$IFDEF D12+}, tkUString{$ENDIF}: FieldType := StringFieldType(FieldName); tkInteger: Modified: trunk/Source/Core/InstantRtti.pas =================================================================== --- trunk/Source/Core/InstantRtti.pas 2009-12-21 09:13:48 UTC (rev 880) +++ trunk/Source/Core/InstantRtti.pas 2009-12-22 19:11:42 UTC (rev 881) @@ -105,6 +105,7 @@ Value: Variant): Variant; var PropInfo: PPropInfo; + PreferStrings: Boolean; begin if Assigned(AObject) then begin @@ -147,7 +148,8 @@ SetPropValue(AObject, InstantGetPropName(PropInfo), Value); end; end; - Result := GetPropValue(AObject, InstantGetPropName(PropInfo)); + PreferStrings := GetTypeInfo(PropInfo)^.Kind <> tkEnumeration; + Result := GetPropValue(AObject, InstantGetPropName(PropInfo), PreferStrings); end else Result := Null; end else |