Преглед изворни кода

sqliteds: simplify FindRecordItem and SetFieldData handling of double values since comparison of double is not done by string value anymore

git-svn-id: trunk@19603 -
blikblum пре 13 година
родитељ
комит
c1ccac04ca
1 измењених фајлова са 5 додато и 21 уклоњено
  1. 5 21
      packages/fcl-db/src/sqlite/customsqliteds.pas

+ 5 - 21
packages/fcl-db/src/sqlite/customsqliteds.pas

@@ -1099,7 +1099,6 @@ var
   AFieldList: TList;
   AFieldList: TList;
   i, AFieldCount: Integer;
   i, AFieldCount: Integer;
   MatchRecord: Boolean;
   MatchRecord: Boolean;
-  AValue: String;
   TempItem: PDataRecord;
   TempItem: PDataRecord;
   
   
 begin
 begin
@@ -1169,10 +1168,9 @@ begin
           LocateFields[i].CompFunction := @CompDouble;
           LocateFields[i].CompFunction := @CompDouble;
           //get float types in appropriate format
           //get float types in appropriate format
           if VarIsArray(KeyValues) then
           if VarIsArray(KeyValues) then
-            Str(VarToDateTime(keyvalues[i]), AValue)
+            Str(VarToDateTime(keyvalues[i]), LocateFields[i].Key)
           else
           else
-            Str(VarToDateTime(keyvalues), AValue);
-          LocateFields[i].Key := Trim(AValue);
+            Str(VarToDateTime(keyvalues), LocateFields[i].Key);
         end;
         end;
         LocateFields[i].Index := FieldNo - 1;
         LocateFields[i].Index := FieldNo - 1;
       end;
       end;
@@ -1324,8 +1322,7 @@ procedure TCustomSqliteDataset.SetFieldData(Field: TField; Buffer: Pointer;
   NativeFormat: Boolean);
   NativeFormat: Boolean);
 var
 var
   TempStr: String;
   TempStr: String;
-  FloatStr: PChar;
-  FloatLen, FieldOffset: Integer;
+  FieldOffset: Integer;
   EditItem: PDataRecord;
   EditItem: PDataRecord;
 begin
 begin
   if not (State in [dsEdit, dsInsert, dsCalcFields]) then
   if not (State in [dsEdit, dsInsert, dsCalcFields]) then
@@ -1371,21 +1368,8 @@ begin
     ftFloat, ftDateTime, ftDate, ftTime, ftCurrency:
     ftFloat, ftDateTime, ftDate, ftTime, ftCurrency:
       begin
       begin
         Str(Double(Buffer^), TempStr);
         Str(Double(Buffer^), TempStr);
-        //Str returns an space as the first character for positive values
-        //and the - sign for negative values. It's necessary to remove the extra
-        //space while keeping the - sign
-        if TempStr[1] = ' ' then
-        begin
-          FloatStr := PChar(TempStr) + 1;
-          FloatLen := Length(TempStr);
-        end
-        else
-        begin
-          FloatStr := PChar(TempStr);
-          FloatLen := Length(TempStr) + 1;
-        end;
-        EditItem^.Row[FieldOffset] := StrAlloc(FloatLen);
-        Move(FloatStr^, (EditItem^.Row[FieldOffset])^, FloatLen);
+        EditItem^.Row[FieldOffset] := StrAlloc(Length(TempStr) + 1);
+        Move(PChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1);
       end;
       end;
     ftLargeInt:
     ftLargeInt:
       begin
       begin