View Issue Details

IDProjectCategoryView StatusLast Update
0025432FPCDatabasepublic2013-12-20 13:13
ReporterReinier OlislagersAssigned ToReinier Olislagers 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx64 (with x86 compiler)OSWindows 
Product Version2.7.1 
Target Version2.7.1Fixed in Version3.0.0 
Summary0025432: Bufdataset/tdbf filter cannot filter for both ' and "
DescriptionFilter 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 InformationProbably 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.
Tagsbufdataset, dbf, filter
Fixed in Revision26249 26253
FPCOldBugId0
FPCTarget
Attached Files

Activities

Michael Van Canneyt

2013-12-17 14:19

administrator   ~0071934

Careful, the string
(NAME='O'Malley's "Magic" Hammer')
is not properly quoted.

It starts with a ', so at least the ' between O and M and y and s must be escaped somehow. It should at least be

(NAME='O\'Malley\'s "Magic" Hammer')
or
(NAME='O''Malley''s "Magic" Hammer')

Reinier Olislagers

2013-12-17 16:11

developer   ~0071935

Last edited: 2013-12-19 16:09

View 3 revisions

@Michael: thanks, yes, I know that name isn't quoted - it's to demonstrate a naive approach which obviously doesn't work ;)
The real problem is that there is no support for escaping delimiters ATM - including an idea of which syntax to use. Agreed with your second proposal.

Implemented test case in 26249.

Issue History

Date Modified Username Field Change
2013-12-17 14:04 Reinier Olislagers New Issue
2013-12-17 14:05 Reinier Olislagers Tag Attached: bufdataset
2013-12-17 14:05 Reinier Olislagers Tag Attached: dbf
2013-12-17 14:05 Reinier Olislagers Tag Attached: filter
2013-12-17 14:19 Michael Van Canneyt Note Added: 0071934
2013-12-17 16:11 Reinier Olislagers Note Added: 0071935
2013-12-17 16:12 Reinier Olislagers File Added: workinprogress_escapedelimitersfilter.diff
2013-12-17 16:12 Reinier Olislagers Fixed in Revision => 26249
2013-12-17 16:13 Reinier Olislagers Note Edited: 0071935 View Revisions
2013-12-19 16:09 Reinier Olislagers File Deleted: workinprogress_escapedelimitersfilter.diff
2013-12-19 16:09 Reinier Olislagers Note Edited: 0071935 View Revisions
2013-12-20 13:13 Reinier Olislagers Fixed in Revision 26249 => 26249 26253
2013-12-20 13:13 Reinier Olislagers Status new => resolved
2013-12-20 13:13 Reinier Olislagers Fixed in Version => 2.7.1
2013-12-20 13:13 Reinier Olislagers Resolution open => fixed
2013-12-20 13:13 Reinier Olislagers Assigned To => Reinier Olislagers
2013-12-20 13:13 Reinier Olislagers Target Version => 2.7.1
2013-12-20 13:13 Reinier Olislagers Status resolved => closed