[fpc-pascal] Dataset indexdefs.find: documentation wrong?

Reinier Olislagers reinierolislagers at gmail.com
Sun Dec 2 17:47:07 CET 2012


With this code:
procedure SortBufDataSet(DataSet: TBufDataSet; const FieldName: string);
var
  Index_Name: string;
begin
  Index_Name := FieldName + '__IdxA';
  if (DataSet.IndexDefs.Find(Index_Name)<>Nil) then
...
the last line throws an exception if the index does not exist;
corresponding db.pas code:
function TIndexDefs.Find(const IndexName: string): TIndexDef;
begin
  Result := (inherited Find(IndexName)) as TIndexDef;
  if (Result=Nil) Then
    DatabaseErrorFmt(SIndexNotFound, [IndexName], FDataSet);
end;

However, the documentation states:
Find...returns Nil if no matching index definition was found.

Not a Delphi guy - should the implementation or the documentation be fixed?

Thanks,
Reinier



More information about the fpc-pascal mailing list