Finer data type mapping
Posted: Mon 29 May 2006 09:20
Hello,
I am in need of doing some finer data type mapping than what is available today through the *Precision settings. In particular, I need to treat NUMBER(1,0) as boolean and NUMBER(15,4) as currency. In order to do that I can see several paths, but all of them involve modifying the dbX driver. I have tried doing it in my middleware code but it gets very messy.
Here are the simplest proposals I could come up with:
a) the driver sets TFieldDef.Precision and TFieldDef.Size even for float and integer fields (that is, when EnableBCD is set to False). In this case the properties would have only an informative meaning; this would allow an application to react accordingly and change the FieldDefs properties simply by overriding InitFieldDefs. In case this behaviour is considered potentially harmful, it could be guarded by a parameter and even be off by default.
As an alternative:
b) the driver supports booleans and currency on its own, by means of new parameters BooleanPrecision and CurrencyPrecision/CurrencySize.
In case option b looks too messy, because of proliferation of parameters, perhaps a cleaner way may be devised:
c) a single new parameter DataTypeMaps of type string is added, which will optionally contain mapping specifications in a simple syntax that the driver will parse after all other mappings are done. This would allow one to support booleans and currency by writing, for example:
{MinPrecision=0;MaxPrecision=1;MinSize=0;MaxSize=0;DataType=ftBoolean}{MinPrecision=15;MaxPrecision=15;MinSize=4;MaxSize=4;DataType=ftCurrency}
I hope one of these proposals, or equivalent functionality that will allow me and others to tune the mappings in a finer way can be implemented in the driver.
Thanks
--
Nando Dessena
I am in need of doing some finer data type mapping than what is available today through the *Precision settings. In particular, I need to treat NUMBER(1,0) as boolean and NUMBER(15,4) as currency. In order to do that I can see several paths, but all of them involve modifying the dbX driver. I have tried doing it in my middleware code but it gets very messy.
Here are the simplest proposals I could come up with:
a) the driver sets TFieldDef.Precision and TFieldDef.Size even for float and integer fields (that is, when EnableBCD is set to False). In this case the properties would have only an informative meaning; this would allow an application to react accordingly and change the FieldDefs properties simply by overriding InitFieldDefs. In case this behaviour is considered potentially harmful, it could be guarded by a parameter and even be off by default.
As an alternative:
b) the driver supports booleans and currency on its own, by means of new parameters BooleanPrecision and CurrencyPrecision/CurrencySize.
In case option b looks too messy, because of proliferation of parameters, perhaps a cleaner way may be devised:
c) a single new parameter DataTypeMaps of type string is added, which will optionally contain mapping specifications in a simple syntax that the driver will parse after all other mappings are done. This would allow one to support booleans and currency by writing, for example:
{MinPrecision=0;MaxPrecision=1;MinSize=0;MaxSize=0;DataType=ftBoolean}{MinPrecision=15;MaxPrecision=15;MinSize=4;MaxSize=4;DataType=ftCurrency}
I hope one of these proposals, or equivalent functionality that will allow me and others to tune the mappings in a finer way can be implemented in the driver.
Thanks
--
Nando Dessena