currency type property is saving only two decimals in PostgreSQL with firedac

I have a property that is of type currency, which can have up to four decimals, which is also mapped to four decimals and when saving it is only two decimals.
I'm using delphi Seattle, PostgreSQL version 10, aurelius version 5.11, FireDac.
with firebird and sqlite databases worked, recorded with four decimals

[Id('FId', TIdGenerator.IdentityOrSequence)]
TMov = class
strict private
[Column('id', [TColumnProp.Required])]
FId: int64;

[Column('quantidade', [TColumnProp.Required], 14,4)]
FQuantidade: currency;

property Id: int64 read FId write FId;
property Quantidade: currency read FQuantidade write FQuantidade;

Are you able to save 4 decimais directly using FireDAC? Aurelius doesn't do much here, only sets the parameter value, "saving" the value to database is up to FireDAC.

yes, but in params you have to use AsBCD or AsFloat. if it is AsCurrency save only with two decimal places

Then it's a FireDAC bug, isn't it?

not. the detail is that you have to choose AsBCD when you want to work with 4 decimals. then I think Aurelius should do this is already parameterized in the Column

If the field data type is ftCurrency, why it doesn't save with 4 decimals?

if it is ft Currency save only with 2 decimals. that's why there is ftBCD to save with 4 decimals. Is it not possible to make this change with the Column's Scale information?

You can try to change the property/field type to Double.

with the Double type saves with more than 2 decimals, but I'll have to guarantee the limit of 4 decimals in the backend so I don't have problems in mathematical operations and comparisons. it would be better for aurelius to differentiate the type when it has more than 2 decimals.

The limit of 4 decimals is provided by your database type, isn't it?
In any case, you can have the field as double in your class, but still use getter/setter to make sure the value has only 4 decimals.

the limitation of 4 decimals is a design definition. yes I could use the get and set of the property, but it would only work in pascal code because xdata directly fills in the field what type would be double

Sorry, I didn't understand what you mean? Could you please elaborate?

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.