Currently, Af-Arch is using PostgreSQL as preferred database backend. However, LibAfGs module is prepared to to support other database backed by only providing six handlers that implements the abstract operations required by the Af-Arch platform.
In fat, current database interation is done through an abstract interface that do not allow to know which is the current database backed, that is actually hosting SQL target query.
However, managing moneraty values on countries where decimal separator is a dot there is no problem but, this is not the same on those countries where this separator is a comma.
This is because the SQL syntax uses the dot as decimal separator and the comma as a lenguage element to separate enumerations.
Being SQL defined this way, decimal separator for european countries is a question which will give problems not only with PostgreSQL but with every SQL database backend.
Now, think about 2 countries which are using diferent decimal separators but they are using the same distribuited system. Values stored must represent the same values but local representation must be used while showing data on client interfaces.AfDalDecimal object is a opaque structure allowing to keep value inside separated from the representation.
At this moment there are supported two sets of function: "dot as decimal separator" and "comma as decimal separator". To chose the current representation function afdal_decimal_set_decimal_separator is used.
The set of function implemented are called: F, F^-1 and C. Their functions are:
F: 100.0 -> 100,0 F: 100.0 -> +100,0
However, due to convinience programming issues, (F) function should also support to receive local value format and return the same number.
To accomplish this requirement, new representation implementation must use C function from inside the F function.
F^-1: 100,0 -> 100.0 F^-1: +100,0 -> 100.0
This allows AfDalDecimal module to perform operation with diferent numbers representations, getting them back to the canonical representation and perform the arithmetical or database operation with them on this state.
This it is also used by afdal_decimal_normalize function to allow AfDal layer to sent to remote servers SQL syntax compliant decimal values.
C: +100,00 -> TRUE C: 100.00 -> FALSE
With the previous function AfDal Decimal module have the hability to change on realtime current decimal format, keep user interface using local representation but using canonical representation while contacting with remote Af-Arch servers nodes.