View Issue Details

IDProjectCategoryView StatusLast Update
0006235JEDI VCL00 JVCL Componentspublic2015-09-14 13:20
ReporterTorbinsAssigned Toobones 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.48 
Summary0006235: TJvMemoryData has unnecessary field
DescriptionTJvMemoryData.FAutoIncField can be safely removed. I have added a patch, to remove it.
TagsNo tags attached.

Activities

2013-12-04 12:56

 

JMD remove FAutoIncField.patch (3,000 bytes)
diff --git "a/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset - \320\232\320\276\320\277\321\226\321\217.pas" "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas"
index ad49617..35c96bc 100644
--- "a/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset - \320\232\320\276\320\277\321\226\321\217.pas"	
+++ "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas"	
@@ -130,7 +130,6 @@ type
     FIndexList: TList;
     FCaseInsensitiveSort: Boolean;
     FDescendingSort: Boolean;
-    FAutoIncField: TField;
     FSrcAutoIncField: TField;
     FDataSet: TDataSet;
     FDataSetClosed: Boolean;
@@ -1981,8 +1980,6 @@ begin
     begin
       Fields[I].Tag := Ord(Fields[I].ReadOnly);
       Fields[I].ReadOnly := False;
-      if Fields[I].DataType = ftAutoInc then
-        FAutoIncField := Fields[I];
     end;
 end;
 
@@ -2051,10 +2048,8 @@ begin
         MovedCount := MaxInt;
       end;
 
-      FinalAutoInc := 0;
-      FAutoIncField := nil;
-      // FixReadOnlyFields also sets FAutoIncField if there is any
       FixReadOnlyFields(False);
+      FinalAutoInc := 0;
       // find first source autoinc field
       FSrcAutoIncField := nil;
       if Mode = lmCopy then
@@ -2070,7 +2065,7 @@ begin
           Append;
           AssignRecord(Source, Self, True);
           // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field)
-          if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then
+          if FSrcAutoIncField <> nil then
           begin
             FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger);
             FAutoInc := FSrcAutoIncField.AsInteger;
@@ -2093,7 +2088,6 @@ begin
         FixReadOnlyFields(True);
         if Mode = lmCopy then
           FAutoInc := FinalAutoInc + 1;
-        FAutoIncField := nil;
         FSrcAutoIncField := nil;
         First;
       end;
@@ -2523,7 +2517,6 @@ begin
       StatusField := FieldByName(FStatusName);
 
     FinalAutoInc := 0;
-    FAutoIncField := nil;
     // find first source autoinc field
     FSrcAutoIncField := nil;
     for I := 0 to FDataSet.FieldCount - 1 do
@@ -2532,8 +2525,6 @@ begin
         FSrcAutoIncField := FDataSet.Fields[I];
         Break;
       end;
-    if FSrcAutoIncField <> nil then
-      FAutoIncField := FindField(FSrcAutoIncField.FieldName);
 
     FDataSet.First;
     while not FDataSet.EOF do
@@ -2559,7 +2550,7 @@ begin
         end;
       end;
       // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field)
-      if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then
+      if FSrcAutoIncField <> nil then
       begin
         FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger);
         FAutoInc := FSrcAutoIncField.AsInteger;

2013-12-04 12:59

 

JMD remove FAutoIncField 2.patch (3,340 bytes)
diff --git "a/D:\\Components\\jvclg\\jvcl\\run\\JvMemoryDataset.pas" "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas"
index 0e7df31..35c96bc 100644
--- "a/D:\\Components\\jvclg\\jvcl\\run\\JvMemoryDataset.pas"
+++ "b/C:\\Users\\User\\Documents\\RAD Studio\\Projects\\JMD AutoIncrement Test\\JvMemoryDataset.pas"	
@@ -130,7 +130,6 @@ type
     FIndexList: TList;
     FCaseInsensitiveSort: Boolean;
     FDescendingSort: Boolean;
-    FAutoIncField: TField;
     FSrcAutoIncField: TField;
     FDataSet: TDataSet;
     FDataSetClosed: Boolean;
@@ -1981,8 +1980,6 @@ begin
     begin
       Fields[I].Tag := Ord(Fields[I].ReadOnly);
       Fields[I].ReadOnly := False;
-      if Fields[I].DataType = ftAutoInc then
-        FAutoIncField := Fields[I];
     end;
 end;
 
@@ -2051,10 +2048,8 @@ begin
         MovedCount := MaxInt;
       end;
 
-      FinalAutoInc := 0;
-      FAutoIncField := nil;
-      // FixReadOnlyFields also sets FAutoIncField if there is any
       FixReadOnlyFields(False);
+      FinalAutoInc := 0;
       // find first source autoinc field
       FSrcAutoIncField := nil;
       if Mode = lmCopy then
@@ -2070,10 +2065,10 @@ begin
           Append;
           AssignRecord(Source, Self, True);
           // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field)
-          if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then
+          if FSrcAutoIncField <> nil then
           begin
             FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger);
-            FAutoInc := FSrcAutoIncField.AsInteger; //SetAutoIncFields will write this value to all fields with ftAutoInc
+            FAutoInc := FSrcAutoIncField.AsInteger;
           end;
           if (Mode = lmCopy) and (FApplyMode <> amNone) then
             FieldByName(FStatusName).AsInteger := Integer(rsOriginal);
@@ -2093,7 +2088,6 @@ begin
         FixReadOnlyFields(True);
         if Mode = lmCopy then
           FAutoInc := FinalAutoInc + 1;
-        FAutoIncField := nil;
         FSrcAutoIncField := nil;
         First;
       end;
@@ -2523,7 +2517,6 @@ begin
       StatusField := FieldByName(FStatusName);
 
     FinalAutoInc := 0;
-    FAutoIncField := nil;
     // find first source autoinc field
     FSrcAutoIncField := nil;
     for I := 0 to FDataSet.FieldCount - 1 do
@@ -2532,8 +2525,6 @@ begin
         FSrcAutoIncField := FDataSet.Fields[I];
         Break;
       end;
-    if FSrcAutoIncField <> nil then
-      FAutoIncField := FindField(FSrcAutoIncField.FieldName);
 
     FDataSet.First;
     while not FDataSet.EOF do
@@ -2559,10 +2550,10 @@ begin
         end;
       end;
       // assign AutoInc value manually (make user keep largest if source isn't sorted by autoinc field)
-      if (FAutoIncField <> nil) and (FSrcAutoIncField <> nil) then
+      if FSrcAutoIncField <> nil then
       begin
         FinalAutoInc := Max(FinalAutoInc, FSrcAutoIncField.AsInteger);
-        FAutoInc := FSrcAutoIncField.AsInteger; //SetAutoIncFields will write this value to all fields with ftAutoInc
+        FAutoInc := FSrcAutoIncField.AsInteger;
       end;
       if FApplyMode <> amNone then
         StatusField.AsInteger := Integer(rsOriginal);

Torbins

2013-12-04 13:01

reporter   ~0020706

I am not familiar with git, but second version of the patch should be better.

obones

2013-12-13 16:13

administrator   ~0020832

I'm sorry, but your patch does not apply cleanly to the current GIT content because FinalAutoInc is nowhere to be seen.

Torbins

2013-12-16 12:19

reporter   ~0020855

Sorry, this patch requires patch from http://issuetracker.delphi-jedi.org/view.php?id=6234 to be applied first.

obones

2013-12-18 15:42

administrator   ~0020883

This is now in GIT

Issue History

Date Modified Username Field Change
2013-12-04 12:56 Torbins New Issue
2013-12-04 12:56 Torbins File Added: JMD remove FAutoIncField.patch
2013-12-04 12:59 Torbins File Added: JMD remove FAutoIncField 2.patch
2013-12-04 13:01 Torbins Note Added: 0020706
2013-12-13 11:10 obones Status new => acknowledged
2013-12-13 16:13 obones Note Added: 0020832
2013-12-13 16:13 obones Status acknowledged => feedback
2013-12-16 12:19 Torbins Note Added: 0020855
2013-12-16 17:48 obones Status feedback => acknowledged
2013-12-18 15:42 obones Note Added: 0020883
2013-12-18 15:42 obones Status acknowledged => resolved
2013-12-18 15:42 obones Fixed in Version => Daily / GIT
2013-12-18 15:42 obones Resolution open => fixed
2013-12-18 15:42 obones Assigned To => obones
2015-09-14 13:20 obones Fixed in Version Daily / GIT => 3.48