TClientDataSet 过滤器是否有限制,或者它是一个错误?

Is there a limit for TClientDataSet filter, or is it a bug?

我正在使用 TClientDataSet 作为内存 table 并且必须应用具有很多条件的过滤器。

例如,在 400 OR 条件下,我在尝试启用过滤器时遇到访问冲突。

Access violation at address 4DAEDC76 in module 'midas.dll'. Read of address 00000034.

此处出现异常:

procedure TCustomClientDataSet.AddExprFilter(const Expr: Widestring; Options: TFilterOptions); 
begin 
  if FExprFilter <> nil then FDSCursor.DropFilter(FExprFilter); 
  if Expr <> '' then 
  with TExprParser.Create(Self, Expr, Options, [poExtSyntax], '', nil, FieldTypeMap, True) do 
    try 
      CheckProviderEOF; 
      Check(FDSCursor.AddFilter(FilterData, DataSize, FExprFilter)); // ** AV HERE
    finally 
      Free; 
    end; 
end; 

它是组件上的错误还是 midas.dll 的限制? 我在这些 midas 版本上测试了这种行为:>= 15 和 <= 23

我正在使用 Delphi XE。 示例代码:

procedure TForm41.Button1Click(Sender: TObject);
var
  I: Integer;
  FilterStr: string;
begin
  FilterStr := '(vehicleId = -1)';
  //It is just an example, the original code I can have any integer number.
  for I := 0 to 400 do //If I change the limit value to 40 for example, it works. 
    FilterStr := FilterStr + ' or (vehicleId = ' + IntToStr(I) + ')';

  ClientDataSet1.Filter := FilterStr;
  ClientDataSet1.Filtered := True;
  ClientDataSet1.CreateDataSet; //Error here
end;

我已经尝试使用 IN 语句,但我得到了同样的错误。

我没有在互联网上找到关于这种情况的参考资料。

我可以重现此错误,包括 Delphi 西雅图的 "Read of address 00000034"。 当 Filter 表达式中的术语超过 280 个时,就会出现这种情况。它是 显然是 midas 限制。您需要一种更好的方法来从您的问题领域进行翻译 达到滤镜的预期效果。

如果您可以在代码中评估您的条件,那么我要做的就是添加 一个 boolean fkInternalCalc 字段到 CDS 并将其设置为 True of False 取决于结果。然后,过滤数据集是一件简单的事情 根据布尔值应用过滤器。