View Issue Details

IDProjectCategoryView StatusLast Update
0036366FPCPackagespublic2019-11-27 10:48
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionno change required 
PlatformallOSallOS Versionall
Product Version3.3.1Product Build43592 
Target VersionFixed in Version 
Summary0036366: TfpExtressionParser: bugs in aggregates min, max, sum, avg, count
DescriptionTfpExtressionParser is not able to parse the above aggregates correctly
Steps To Reproduce{$mode delphi}
uses
 sysutils, fpexprpars,math;
var
  FParser: TFPExpressionParser;
begin
  FParser := TFPExpressionParser.Create(nil);
  try
    FParser.Builtins :=[bcStrings,bcDateTime,bcMath,bcBoolean,bcConversion,bcData,bcVaria,bcUser,bcAggregate];
    try
      writeln(8 mod 3);
      FParser.Expression := '8 mod 3'; // mod works in trunk
      FParser.Evaluate;
      writeln(FParser.AsInteger);
    except
      On E:EExprParser do
        writeln(E.Message)
      else Raise;
    end;

    try
      writeln(min(3,5));
      FParser.Expression := 'min(3,5)'; // but this fails
      FParser.Evaluate;
      writeln(FParser.AsInteger);
    except
      on E:EExprParser do
        writeln(E.Message)
      else Raise;
    end;
  finally
    FParser.Free;
  end;
end.
Additional InformationSee discussion here: https://forum.lazarus.freepascal.org/index.php/topic,19627.msg340744.html#msg340744
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Thaddy de Koning

2019-11-27 10:37

reporter   ~0119523

Output of the above is:
2
2
3
Expected ) bracket at position 7, but got ,

Thaddy de Koning

2019-11-27 10:41

reporter   ~0119524

I do not know what a TfpExtressionParser is but that is obviously that my keyboard not always understands me. ;)
TfpExpressionParser

Michael Van Canneyt

2019-11-27 10:48

administrator   ~0119525

The aggregates are not meant to be used like that.

They're meant to be evaluated successively in a series of evaluations, as in SQL:
min(myfield).

See the test cases for use examples




Issue History

Date Modified Username Field Change
2019-11-27 10:36 Thaddy de Koning New Issue
2019-11-27 10:37 Thaddy de Koning Note Added: 0119523
2019-11-27 10:41 Thaddy de Koning Note Added: 0119524
2019-11-27 10:48 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-11-27 10:48 Michael Van Canneyt Status new => resolved
2019-11-27 10:48 Michael Van Canneyt Resolution open => no change required
2019-11-27 10:48 Michael Van Canneyt FPCTarget => -
2019-11-27 10:48 Michael Van Canneyt Note Added: 0119525