Page 1 of 1
ZMemTable does not support the ftCurrency type
Posted: 01.05.2024, 15:52
by abonic
Steps to reproduce problem:
Code: Select all
ZMemTable1.Active := False;
ZMemTable1.FieldDefs.Clear;
ZMemTable1.FieldDefs.Add('price', ftCurrency);
ZMemTable1.Open; // <- Error: ZMemTable1: Type mismatch for field 'price', expecting: Blob actual: Currency.
I think the error is in:
Code: Select all
TZAbstractRODataset.GetFieldClass(FieldType: TFieldType): TFieldClass;
There is no translation defined for the ftCurrency type in that function, so it ends up as TZBLobField.
Re: ZMemTable does not support the ftCurrency type
Posted: 02.05.2024, 17:10
by aehimself
The issue is not that simple. Either we simply add a TCurrencyField (which is probably undesirable considering all the TZxxField variants) in the method you mentioned but the good solution is to implement the currently missing TZCurrencyField.
I don't have access to any RDBMSes at the moment but it would be interesting to check how TZ(ReadOnly)Query behaves, what kind of field it creates when the query returns an actual currency field. I will be able to test this on Sunday, when I will be back from abroad.
Re: ZMemTable does not support the ftCurrency type
Posted: 07.05.2024, 17:23
by marsupilami
I added a TZCurrencyField. TZMemTable should now be able to create a corresponding field. Please test the
current version of the 8.0-patches branch.
Note: T(Z)CurrencyField is derived from TFloatField - so doesn't do exact numerics. We discourage the usage of this field type. Please use one of the BCD field types and set the Currency property to true.
Re: ZMemTable does not support the ftCurrency type
Posted: 08.05.2024, 08:58
by abonic
It works as it should, it seems. Thank you.
I have already opted for ftBcd in my application. The attempt with ftCurrency was just a quick prototype.
I absolutely agree that this field type (with a very misleading name) should be avoided, but I think it's good for ZEOS to support it now, even if it's only for compatibility and completeness.
Re: ZMemTable does not support the ftCurrency type
Posted: 08.05.2024, 09:56
by marsupilami
aehimself wrote: ↑02.05.2024, 17:10
I don't have access to any RDBMSes at the moment but it would be interesting to check how TZ(ReadOnly)Query behaves, what kind of field it creates when the query returns an actual currency field. I will be able to test this on Sunday, when I will be back from abroad.
According to EgonHugeist Zeos never creates fields of the kind fkCurrency - which probably is why we didn't have a TZCurrencyField. Instead one of the BCD field types should be created. Maybe we set the currency property to true too.