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.