Browse Source

fcl-db: sqlite: bind boolean parameters according to SQLite expectation:
"Boolean values are stored as integers 0 (false) and 1 (true)."
Until now True was stored as -1 instead of 1. (Reading is correct as "True" is "<>0").
This is potentialy breaking change, DO NOT BACKPORT IT!

git-svn-id: trunk@31086 -

lacak 10 years ago
parent
commit
5e8d1078a7
1 changed files with 3 additions and 11 deletions
  1. 3 11
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

+ 3 - 11
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -178,7 +178,6 @@ Var
   I : Integer;
   I : Integer;
   P : TParam;  
   P : TParam;  
   str1: string;
   str1: string;
-  do1: double;
   wstr1: widestring;
   wstr1: widestring;
   
   
 begin
 begin
@@ -191,23 +190,16 @@ begin
       case P.DataType of
       case P.DataType of
         ftInteger,
         ftInteger,
         ftAutoInc,
         ftAutoInc,
-        ftBoolean,
         ftSmallint: checkerror(sqlite3_bind_int(fstatement,I,P.AsInteger));
         ftSmallint: checkerror(sqlite3_bind_int(fstatement,I,P.AsInteger));
         ftWord:     checkerror(sqlite3_bind_int(fstatement,I,P.AsWord));
         ftWord:     checkerror(sqlite3_bind_int(fstatement,I,P.AsWord));
+        ftBoolean:  checkerror(sqlite3_bind_int(fstatement,I,ord(P.AsBoolean)));
         ftLargeint: checkerror(sqlite3_bind_int64(fstatement,I,P.AsLargeint));
         ftLargeint: checkerror(sqlite3_bind_int64(fstatement,I,P.AsLargeint));
         ftBcd,
         ftBcd,
         ftFloat,
         ftFloat,
-        ftCurrency:
-                begin
-                do1:= P.AsFloat;
-                checkerror(sqlite3_bind_double(fstatement,I,do1));
-                end;
+        ftCurrency: checkerror(sqlite3_bind_double(fstatement, I, P.AsFloat));
         ftDateTime,
         ftDateTime,
         ftDate,
         ftDate,
-        ftTime: begin
-                do1:= P.AsFloat - JulianEpoch;
-                checkerror(sqlite3_bind_double(fstatement,I,do1));
-                end;
+        ftTime:     checkerror(sqlite3_bind_double(fstatement, I, P.AsFloat - JulianEpoch));
         ftFMTBcd:
         ftFMTBcd:
                 begin
                 begin
                 str1:=BCDToStr(P.AsFMTBCD, Fconnection.FSQLFormatSettings);
                 str1:=BCDToStr(P.AsFMTBCD, Fconnection.FSQLFormatSettings);