Bufdataset/tdbf filter cannot filter for both ' and "
Original Reporter info from Mantis: BigChimp
-
Reporter name: Reinier Olislagers
Original Reporter info from Mantis: BigChimp
- Reporter name: Reinier Olislagers
Description:
Filter strings on both ' and " characters, e.g.
Filter:='(NAME=''O''Malley''s "Magic" Hammer'')';
which gives
(NAME='O'Malley's "Magic" Hammer')
give errors like
Exception: Missing operator between ''O'' and ''O''
see e.g. thread http://forum.lazarus.freepascal.org/index.php/topic,22855.msg136436.html#msg136436
Proposal: allow escaping delimiters by doubling them e.g.
Filter:='(NAME=''O''''Malley''''s "Magic" Hammer'')';
which gives
(NAME='O''Malley''s "Magic" Hammer')
Additional information:
Probably due to
dbf_prscore
procedure TCustomExpressionParser.ParseString(AnExpression: string; DestCollection: TExprCollection);
...
procedure ReadWord(AnExpr: string);
...
case AnExpr[I2] of
'''', '"':
begin
isConstant := true;
constChar := AnExpr[I2];
Inc(I2);
while (I2 <= Len) and (AnExpr[I2] <> constChar) do
Inc(I2);
if I2 <= Len then
Inc(I2);
end;
which only checks for beginning and ending delimiters (Delimiters can be either ' or "). This means delimiters within the string are not accepted as such.