Browse Source

fcl-db/dbase: fix for HasBlob only returning true if last field is blob

git-svn-id: trunk@24340 -
reiniero 12 years ago
parent
commit
e78c2e05ef

+ 6 - 3
packages/fcl-db/src/dbase/dbf_dbffile.pas

@@ -68,7 +68,7 @@ type
     FDateTimeHandling: TDateTimeHandling;
     FOnLocaleError: TDbfLocaleErrorEvent;
     FOnIndexMissing: TDbfIndexMissingEvent;
-
+    // Yes if table has blob/memo type field(s) (storage in external file)
     function  HasBlob: Boolean;
     function  GetMemoExt: string;
 
@@ -686,7 +686,7 @@ begin
     end;
     // begin writing field definitions
     FFieldDefs.Clear;
-    // deleted mark 1 byte
+    // deleted mark takes 1 byte, so skip over that
     lFieldOffset := 1;
     for I := 1 to AFieldDefs.Count do
     begin
@@ -875,8 +875,11 @@ var
 begin
   Result := false;
   for I := 0 to FFieldDefs.Count-1 do
-    if FFieldDefs.Items[I].IsBlob then 
+    if FFieldDefs.Items[I].IsBlob then
+    begin
       Result := true;
+      break;
+    end;
 end;
 
 function TDbfFile.GetMemoExt: string;

+ 1 - 0
packages/fcl-db/src/dbase/dbf_fields.pas

@@ -66,6 +66,7 @@ type
     procedure CheckSizePrecision;
     procedure SetDefaultSize;
     procedure AllocBuffers;
+    // Yes if field is a blob/memo type field (storage in external file)
     function  IsBlob: Boolean;
 
     property DefaultBuf: PChar read FDefaultBuf;

+ 1 - 1
packages/fcl-db/tests/dbftoolsunit.pas

@@ -38,7 +38,7 @@ type
   end;
 
   { TDBFAutoClean }
-  // DBF descendant that saves to a temp file and removes file when closed
+  // DBF descendant that saves to a memory stream instead of file
   TDBFAutoClean = class(TDBF)
   private
     FBackingStream: TMemoryStream;

+ 1 - 1
packages/fcl-db/tests/testspecifictdbf.pas

@@ -90,7 +90,7 @@ begin
     CheckEquals('TestName' + inttostr(i),ADBFDataset.fieldbyname('NAME').AsString);
     ADBFDataset.next;
     end;
-  CheckTrue(ADBFDataset.EOF);
+  CheckTrue(ADBFDataset.EOF,'After reading all records the dataset should show EOF');
 end;