Commits

reiniero  committed e052ed4

Hopefully fix calculated fields

  • Participants
  • Parent commits 160c8d5

Comments (0)

Files changed (1)

File dbasetests/testspecifictdbf.pas

   f: TField;
 begin
   ds := TDBFAutoClean.Create(nil);
+  DS.CreateTable;
   F := TIntegerField.Create(ds);
   F.FieldName:='ID';
   F.DataSet:=ds;
   F.FieldName:='NAME';
   F.DataSet:=ds;
   F.Size:=50;
-  DS.CreateTable;
+
   DS.Open;
   ds.free;
 end;
   //todo: find out which tablelevels support calculated/lookup fields
   ds := TDBFAutoClean.Create(nil);
   try
-    F := TIntegerField.Create(ds);
-    F.FieldName:='ID';
-    F.DataSet:=ds;
-
-    F := TStringField.Create(ds);
-    F.FieldName:='NAME';
-    F.DataSet:=ds;
-    F.Size:=50;
+    ds.FieldDefs.Add('ID',ftInteger);
+    ds.FieldDefs.Add('NAME',ftString,50);
+    ds.CreateTable;
+    for i:=0 to ds.FieldDefs.Count-1 do
+    begin
+      ds.FieldDefs[i].CreateField(ds); // make fields persistent
+    end;
 
     F := TStringField.Create(ds);
     F.FieldKind:=fkCalculated;
     F.FieldName:='NAME_CALC';
     F.DataSet:=ds;
     F.Size:=50;
+    F.ProviderFlags:=[];
 
     F := TStringField.Create(ds);
     F.FieldKind:=fkLookup;
     F.DataSet:=ds;
     F.Size:=50;
 
-    DS.CreateTable;
     DS.Open;
     WriteReadbackTest(ds);