View Issue Details

IDProjectCategoryView StatusLast Update
0038988pas2jsrtlpublic2021-06-11 14:10
Reporterhenrique Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformPas2JsOSWindows 
Fixed in Versiontrunk 
Summary0038988: Calculate fields problem
DescriptionI came across a problem in the calculated fields.

When you set the function to calculated field, and changed the value of a data field, the event was triggered, the dataset status was as dsCalc and not dsInsert.

I made an adjustment to change the status, only when you are loading the records and not when you are changing the values of a field.

So the behavior of the dataset is the same as delphi's.
TagsNo tags attached.
Fixed in Revision1200
Attached Files

Activities

henrique

2021-06-11 14:04

reporter  

0001-Deixar-os-campos-calculados-com-o-mesmo-esquema-do-D.patch (1,850 bytes)   
From 5717dfca53af8e0d58fd7eb4a6eeb87df23af255 Mon Sep 17 00:00:00 2001
From: Henrique Gottardi Werlang <henriquewerlang@hotmail.com>
Date: Fri, 11 Jun 2021 10:59:22 -0300
Subject: [PATCH] Deixar os campos calculados com o mesmo esquema do Delphi.

---
 packages/fcl-db/db.pas | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/packages/fcl-db/db.pas b/packages/fcl-db/db.pas
index e4a4092c..4546700b 100644
--- a/packages/fcl-db/db.pas
+++ b/packages/fcl-db/db.pas
@@ -2464,24 +2464,20 @@ end;
 procedure TDataSet.CalculateFields(var Buffer: TDataRecord);
 var
   i: Integer;
-  OldState: TDatasetState;
 begin
   FCalcBuffer := Buffer;
+
   if FState <> dsInternalCalc then
   begin
-    OldState := FState;
-    FState := dsCalcFields;
-    try
-      ClearCalcFields(FCalcBuffer);
-      if not IsUniDirectional then
-        for i := 0 to FFieldList.Count - 1 do
-          if FFieldList[i].FieldKind = fkLookup then
-            FFieldList[i].CalcLookupValue;
-    finally
-      DoOnCalcFields;
-      FState := OldState;
-    end;
+    ClearCalcFields(FCalcBuffer);
+
+    if not IsUniDirectional then
+      for i := 0 to FFieldList.Count - 1 do
+        if FFieldList[i].FieldKind = fkLookup then
+          FFieldList[i].CalcLookupValue;
   end;
+
+  DoOnCalcFields;
 end;
 
 procedure TDataSet.CheckActive;
@@ -3142,10 +3138,20 @@ begin
 end;
 
 procedure TDataSet.GetCalcFields(var Buffer: TDataRecord);
-
+var
+  i: Integer;
+  OldState: TDatasetState;
 begin
   if (FCalcFieldsCount > 0) or FInternalCalcFields then
-    CalculateFields(Buffer);
+  begin
+    OldState := FState;
+    FState := dsCalcFields;
+    try
+      CalculateFields(Buffer);
+    finally
+      FState := OldState;
+    end;
+  end;
 end;
 
 function TDataSet.GetCanModify: Boolean;
-- 
2.31.1.windows.1

Michael Van Canneyt

2021-06-11 14:10

administrator   ~0131258

Thanks, applied !

Issue History

Date Modified Username Field Change
2021-06-11 14:04 henrique New Issue
2021-06-11 14:04 henrique File Added: 0001-Deixar-os-campos-calculados-com-o-mesmo-esquema-do-D.patch
2021-06-11 14:10 Michael Van Canneyt Assigned To => Michael Van Canneyt
2021-06-11 14:10 Michael Van Canneyt Status new => resolved
2021-06-11 14:10 Michael Van Canneyt Resolution open => fixed
2021-06-11 14:10 Michael Van Canneyt Fixed in Version => trunk
2021-06-11 14:10 Michael Van Canneyt Fixed in Revision => 1200
2021-06-11 14:10 Michael Van Canneyt Note Added: 0131258