From 2e706f483f146c637de2c4b10c116f69ae2f517c Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Sun, 3 Nov 2024 22:48:04 +0100 Subject: [PATCH] Updated TemplatePro --- sources/MVCFramework.View.Renderers.TemplatePro.pas | 6 +++++- sources/TemplatePro.pas | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sources/MVCFramework.View.Renderers.TemplatePro.pas b/sources/MVCFramework.View.Renderers.TemplatePro.pas index 22a08e39..69ab30dd 100644 --- a/sources/MVCFramework.View.Renderers.TemplatePro.pas +++ b/sources/MVCFramework.View.Renderers.TemplatePro.pas @@ -96,7 +96,11 @@ var begin if not aValue.IsObject then begin - Result := '(Error: Cannot serialize non-object as JSON)'; + if aValue.IsType then + begin + Exit(aValue.AsInt64); + end; + Exit('(Error: Cannot serialize non-object as JSON)'); end; if TDuckTypedList.CanBeWrappedAsList(aValue.AsObject, lWrappedList) then diff --git a/sources/TemplatePro.pas b/sources/TemplatePro.pas index db6f7939..e8e8f5df 100644 --- a/sources/TemplatePro.pas +++ b/sources/TemplatePro.pas @@ -459,7 +459,11 @@ function TTProCompiledTemplate.GetDataSetFieldAsTValue(const aDataSet: TDataSet; var lField: TField; begin - lField := aDataSet.FieldByName(FieldName); + lField := aDataSet.FindField(FieldName); + if not Assigned(lField) then + begin + Exit(TValue.Empty); + end; case lField.DataType of ftInteger, ftSmallInt, ftWord: Result := lField.AsInteger;