Browse Source

* On TDataset.Edit exit the method when the state is dsEdit or dsInsert before CheckBrowseMode is called, because CheckBrowseMode will always set the state to dsBrowse. (+test)

git-svn-id: trunk@12515 -
joost 16 years ago
parent
commit
d844200495
3 changed files with 32 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      packages/fcl-db/src/base/dataset.inc
  3. 30 0
      tests/test/packages/fcl-db/tdb4.pp

+ 1 - 0
.gitattributes

@@ -7669,6 +7669,7 @@ tests/test/packages/fcl-db/dbftoolsunit.pas svneol=native#text/plain
 tests/test/packages/fcl-db/tdb1.pp svneol=native#text/plain
 tests/test/packages/fcl-db/tdb2.pp svneol=native#text/plain
 tests/test/packages/fcl-db/tdb3.pp svneol=native#text/plain
+tests/test/packages/fcl-db/tdb4.pp svneol=native#text/plain
 tests/test/packages/fcl-db/toolsunit.pas svneol=native#text/plain
 tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
 tests/test/packages/hash/tmdtest.pp svneol=native#text/plain

+ 1 - 1
packages/fcl-db/src/base/dataset.inc

@@ -1669,10 +1669,10 @@ end;
 Procedure TDataset.Edit;
 
 begin
+  If State in [dsedit,dsinsert] then exit;
   CheckBrowseMode;
   If Not CanModify then
     DatabaseError(SDatasetReadOnly,Self);
-  If State in [dsedit,dsinsert] then exit;
   If FRecordCount = 0 then
     begin
     Append;

+ 30 - 0
tests/test/packages/fcl-db/tdb4.pp

@@ -0,0 +1,30 @@
+program TestMemDs;
+
+{$mode objfpc}{$H+}
+
+uses
+  memds,db;
+
+var
+   DSet:TMemDataset;
+
+begin
+   DSet:=TMemDataset.Create(nil);
+   DSet.FieldDefs.Add('NAME',ftString,20);
+   DSet.CreateTable;
+   DSet.Open;
+
+   DSet.Append;
+   DSet.Edit;
+   DSet.FieldByName('NAME').Value:='aaa';
+   DSet.Post;
+
+   DSet.Append;
+   DSet.Edit;
+   DSet.FieldByName('NAME').Value:='bbb';
+   DSet.Post;
+
+   if Dset.RecordCount<>2 then
+     halt(1);
+   DSet.Free;
+end.