SQLite NUMERIC,DECIMAL columns with scale > 4
Original Reporter info from Mantis: lacak @lacak.sk
-
Reporter name: LacaK
Original Reporter info from Mantis: lacak @lacak.sk
- Reporter name: LacaK
Description:
In sqlite3conn.pp NUMERIC and DECIMAL columns are mapped to ftBCD Fields.
But if they have scale > 4 exception is raised, because ftBCD fields allow only 0-4 decimal places (they use currency datatype).
SQLite handles NUMERIC and DECIMAL columns as "NUMERIC" (see 2.2 Affinity Name Examples http://www.sqlite.org/datatype3.html#affinity )
Columns with NUMERIC affinity may store values which are internaly stored as INTEGERS (1-8 bytes) or REAL (8 bytes).
So patch 1 uses this logic if column is DECIMAL(x,0) then remap to ftLargeInt (able to hold largest integer supported my SQLite),
when column is DECIMAL(x,y), where Y>4 then remap to ftFloat, otherwise ftBCD
Patch 2 contains my prior attempt to implement ftFMTBcdField. It may be used as initial implementation, but in some cases I use conversions from BCD to double, because fmtbcd.pp does not implement all necessary functions ATM. (see http://bugs.freepascal.org/view.php?id=16853)
Mantis conversion info:
- Mantis ID: 16924
- Version: 2.5.1
- Fixed in version: 3.0.0
- Fixed in revision: 18988 (#d630a85c)