Browse Source

TCustomBufDataset: don't allow PacketRecords=-1 on a UniDirectional dataset. Issue #36884

git-svn-id: trunk@44634 -
ondrej 5 years ago
parent
commit
3f5f91f194
2 changed files with 7 additions and 3 deletions
  1. 6 3
      packages/fcl-db/src/base/bufdataset.pas
  2. 1 0
      packages/fcl-db/src/base/dbconst.pas

+ 6 - 3
packages/fcl-db/src/base/bufdataset.pas

@@ -998,10 +998,13 @@ procedure TCustomBufDataset.SetPacketRecords(aValue : integer);
 begin
 begin
   if (aValue = -1) or (aValue > 0) then
   if (aValue = -1) or (aValue > 0) then
     begin
     begin
-    if (IndexFieldNames='') then
+    if (IndexFieldNames<>'') and (aValue<>-1) then
+      DatabaseError(SInvPacketRecordsValueFieldNames)
+    else
+    if UniDirectional and (aValue=-1) then
+      DatabaseError(SInvPacketRecordsValueUniDirectional)
+    else
       FPacketRecords := aValue
       FPacketRecords := aValue
-    else if AValue<>-1 then
-      DatabaseError(SInvPacketRecordsValueFieldNames);
     end
     end
   else
   else
     DatabaseError(SInvPacketRecordsValue);
     DatabaseError(SInvPacketRecordsValue);

+ 1 - 0
packages/fcl-db/src/base/dbconst.pas

@@ -85,6 +85,7 @@ Resourcestring
   SUnsupportedFieldType    = 'Fieldtype %s is not supported';
   SUnsupportedFieldType    = 'Fieldtype %s is not supported';
   SInvPacketRecordsValue   = 'PacketRecords has to be larger then 0';
   SInvPacketRecordsValue   = 'PacketRecords has to be larger then 0';
   SInvPacketRecordsValueFieldNames = 'PacketRecords must be -1 if IndexFieldNames is set';
   SInvPacketRecordsValueFieldNames = 'PacketRecords must be -1 if IndexFieldNames is set';
+  SInvPacketRecordsValueUniDirectional = 'PacketRecords must not be -1 on an unidirectional dataset';
   SInvalidSearchFieldType  = 'Searching in fields of type %s is not supported';
   SInvalidSearchFieldType  = 'Searching in fields of type %s is not supported';
   SDatasetEmpty            = 'The dataset is empty';
   SDatasetEmpty            = 'The dataset is empty';
   SFieldIsNull             = 'The field is null';
   SFieldIsNull             = 'The field is null';