Menu

#605 Aggregate function like SUM not working on NON persistant fields

Unknown
open
nobody
SVN Trunk (1)
Bug Report
2024-08-01
2024-07-23
No

Somehow strange behaviour of ZQuery:

A SQL-Query like SUM(FieldName) on non persistant fields leads to strange Display like 9,9E2. But if you copy this 9,9E2 by Ctrl+c from DBGrid you have the correct value in clipboard!

The following example app uses ZeosLib and Lazarus SQLConnection and there you can see its only ZeosLib having this sissue.

See example application here:

https://drive.google.com/file/d/1-0-3WkanJI4nXDzvy7dYimCI8JaelOTW/view?usp=sharing

again this URL:

https://drive.google.com/file/d/1-0-3WkanJI4nXDzvy7dYimCI8JaelOTW/view?usp=sharing

I am using Manjaro Linux , trunk version of ZeosLib and "Lazarus 3.99 (rev main_3_99-2278-ge572621c4b) FPC 3.2.2 x86_64-linux-gtk2"

Hope thats all the needed information?!

Thanks for ZeosLib !!!

John Landmesser

Discussion

  • john landmesser

    john landmesser - 2024-07-23

    Sorry, i did forget to mention: it is a sqlite3 Database !

     
  • john landmesser

    john landmesser - 2024-07-23

    What i recognized: this issue only appears on values with fractional part as 10,5 !

     
  • john landmesser

    john landmesser - 2024-07-23
    • summary: Agregate function like SUM not working on NON persistant fields --> Aggregate function like SUM not working on NON persistant fields
     
  • marsupilami79

    marsupilami79 - 2024-08-01

    Hello John,

    we are a bit perplexed because we can see the problem but don't know why the numbers get formatted in a different way with Zeos.

    As a workaround I can only suggest to use the DisplayFormat property of the field for now:

    procedure TForm1.ZQuery1AfterOpen(DataSet: TDataSet);
    begin
      (DataSet.Fields[0] as TFloatField).DisplayFormat := '#,##0.00';
    end;
    

    Best regards,

    Jan

     
  • john landmesser

    john landmesser - 2024-08-01

    Thanks Jan !

    Thanks to google i use allready this workaround :-)

    But why this issue only appears if there are fractional parts in the result and why SQLConnection and SQlite console apps don't have this issue ?

    Dezimalseparator "." as in sqlite is transfered in DBGrid to comma, perhaps here arises the issue?

    I have no experience in debugging components and i can live with that restriction of ZeosLib.

    Keep this issue in mind, sometimes the solution comes "suddenly"

     
    • john landmesser

      john landmesser - 2024-08-01

      SQL-Query does NOT change decimalseparator from dot to comma:

      From the example app: 990.32899999999995

       

Log in to post a comment.