delphidelphi-7unidac

Calculated fields are empty when using unidac in delphi 7


I am using unidac components in a Delphi 7 project to connect to a SQLite database. Connecting and quering works fine, except for calculated fields.

My query is this :

select  c.CardID,
    c.FirstName,
    c.SurName,
    c.Street,
    c.City,
    c.PostCode,
    c.Points,
    (select count(1) from FullCard f where f.CardID = c.CardID and f.Paid = 1) as PaidCards,
    (select count(1) from FullCard f where f.CardID = c.CardID and f.Paid = 0) as OpenCards,
    (select count(1) from FullCard f where f.CardID = c.CardID) as FullCards
from    Card c

This query returns a correct resultset when I run it in SQLiteStudio, but when I run it in delphi the Calculated fields are all empty.

The unidac version is 5.0.1 for Delphi 7.
I have a UniConnection component and a UniQuery component. The connection properties seem correct since I can connect and query from the database.
The UniQuery component has the SQL property filled with the above query, and all fields are made persistent.
When I do UniQuery1.Open a DBGrid fills up with all records, but the fields PaidCards, OpenCards and FullCards are all empty.
The same query does returns these fields properly filled when executing it in SQLiteStudio so I guess there is nothing wrong with the query itself.

I am hoping someone else has encountered the same problem and can point me to a solution for this problem.


Solution

  • The workaround for this bug is not using persistent fields. When I don't create persistent fields than all fields are filled properly and everything works perfect. Only downfall is I have to use query1.FieldByName('FirstName').asString in stead of query1FirstName.asString in my code.