Skip to content

Commit

Permalink
Fixes serialization of enumerations from dataset (#755)
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Zanini <[email protected]>
  • Loading branch information
zaniniflz and Francisco Zanini authored Jun 9, 2024
1 parent 07e16a3 commit 6e07eb8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sources/MVCFramework.Serializer.Commons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,15 @@ procedure MapDataSetFieldToRTTIField(const AField: TField; const aRTTIField: TRt
// general enumerations
else if (aRTTIField.FieldType.TypeKind = tkEnumeration) then
begin
TValue(AField.AsInteger).ExtractRawData(PByte(Pointer(AObject)) + aRTTIField.Offset);
var Value: TValue;
case aRTTIField.FieldType.TypeSize of
SizeOf(Byte): Value := TValue.From<Byte>(AField.AsInteger);
SizeOf(Word): Value := TValue.From<Word>(AField.AsInteger);
SizeOf(Integer): Value := TValue.From<Integer>(AField.AsInteger);
else
raise EMVCException.CreateFmt('Unsupported enumeration type for field %s', [AField.FieldName]);
end;
Value.ExtractRawData(PByte(Pointer(AObject)) + aRTTIField.Offset);
end
// plain integers
else
Expand Down

0 comments on commit 6e07eb8

Please sign in to comment.