[fpc-devel] Implementing TFmtBCDField - ftFmtBCD and SQLite
LacaK
lacak at zoznam.sk
Fri Apr 1 15:26:26 CEST 2011
> No, map to ftfmtbcd, as it should. That will work fine as long as the
> values are within the sqlite-range.
>
ok. in reading phase no problem
(ATM we read using sqlite3_column_text (so SQLite converts all storage
classes (integer,real, blob) to string) and then converting to TBCD ... ok
>
> (Well, show me the bug: as it is now, he won't get an exception? Just
> map to ftmbcd)
yes now no exception it is ok as is
> the user will only get an invalid value when he stores a
> value outside the sqlite-precision scope. Exactly what he would expect
> when he uses sqlite.
>
Yes.
I can live with this, but do not forget, that ATM there is not
implemented writting of ftFmtBCD parameters in Procedure
TSQLite3Cursor.bindparams(AParams : TParams);
So writting never occurs!
So there we must add at least ftFmtBCD case, (behind ftbcd)
But If we add this code (excuse me, I must offer it) ;-):
//it is only pseudo code
ftFmtBCD:
begin
if P.AsFMTBCD.Precision > 15 then //we are out-of-range
begin
str1:=BCDTOStr(P.AsFMTBCD, SQLFormatSettings);
checkerror(sqlite3_bind_blob(fstatement,I,pcharstr(str1),
length(str1), at freebindstring));
end
else
begin
do1:=P.AsFloat;
checkerror(sqlite3_bind_double(fstatement,I,do1));
end;
end;
// all.
Then all cases will be covered and no additional work around are needed.
Laco.
P.S.: P.AsFMTBCD: http://bugs.freepascal.org/view.php?id=18809
More information about the fpc-devel
mailing list