Browse Source

* Allow setting autoinc fields in dsFilter,dsSetKey,dsInsert. Mantis #17624, patch by Lacak2.

git-svn-id: trunk@20943 -
marco 13 years ago
parent
commit
e76a0c1d46
2 changed files with 7 additions and 3 deletions
  1. 1 2
      packages/fcl-db/src/base/bufdataset.pas
  2. 6 1
      packages/fcl-db/src/base/fields.inc

+ 1 - 2
packages/fcl-db/src/base/bufdataset.pas

@@ -3045,9 +3045,8 @@ begin
   end;
 
   // Set The filter-buffer
-  StoreDSState:=State;
+  StoreDSState:=SetTempState(dsFilter);
   FFilterBuffer:=FCurrentIndex.SpareBuffer;
-  SetTempState(dsFilter);
   SetFieldValues(keyfields,KeyValues);
   CurrLinkItem := (FCurrentIndex as TDoubleLinkedBufIndex).FFirstRecBuf;
   FilterBuffer:=IntAllocRecordBuffer;

+ 6 - 1
packages/fcl-db/src/base/fields.inc

@@ -1752,7 +1752,12 @@ end;
 Procedure TAutoIncField.SetAsLongint(AValue : Longint);
 
 begin
-  DataBaseError(SCantSetAutoIncfields);
+  // Some databases allows insertion of explicit values into identity columns
+  // (some of them also allows (some not) updating identity columns)
+  // So allow it at client side and leave check for server side
+  if not(FDataSet.State in [dsFilter,dsSetKey,dsInsert]) then
+    DataBaseError(SCantSetAutoIncFields);
+  inherited;
 end;
 
 { TFloatField }