Error in TZAbstractDatabaseMetadata.HasNoWildcards

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
andrem
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 10.06.2014, 18:48

Error in TZAbstractDatabaseMetadata.HasNoWildcards

Post by andrem »

This function returns "inverted" result:

Code: Select all

{**
   Check if pattern does not contain wildcards
   @param Pattern a sql pattern
   @return if pattern contain wildcards return true otherwise false
}
function TZAbstractDatabaseMetadata.HasNoWildcards(const Pattern: string
  ): boolean;
var
  I: Integer;
  PreviousCharWasEscape: Boolean;
  EscapeChar,PreviousChar: Char;
  WildcardsSet: TZWildcardsSet;
begin
  Result := False;
  PreviousChar := #0;
  PreviousCharWasEscape := False;
  EscapeChar := Char(GetDatabaseInfo.GetSearchStringEscape[1]);
  WildcardsSet := GetWildcardsSet;
  for I := 1 to Length(Pattern) do
  begin
    if (not PreviousCharWasEscape) and CharInset(Pattern[I], WildcardsSet) then
     Exit;

    PreviousCharWasEscape := (Pattern[I] = EscapeChar) and (PreviousChar <> EscapeChar);
    if (PreviousCharWasEscape) and (Pattern[I] = EscapeChar) then
      PreviousChar := #0
    else
      PreviousChar := Pattern[I];
  end;
  Result := True;
end;

Result must be false with wildcards in pattern.
Post Reply