Browse Source

sqliteds: fix locate in float / datetime fields. Bug #20545. Patch by Ludo Brands

git-svn-id: trunk@19602 -
blikblum 13 years ago
parent
commit
f55bf0ff05
1 changed files with 14 additions and 1 deletions
  1. 14 1
      packages/fcl-db/src/sqlite/customsqliteds.pas

+ 14 - 1
packages/fcl-db/src/sqlite/customsqliteds.pas

@@ -1067,6 +1067,19 @@ begin
     Result := False;
 end;
 
+function CompDouble(UTF8Value: PChar; const UTF8Key: String): Boolean;
+var e1,e2:double;
+begin
+  if UTF8Value <> nil then
+    begin
+      val(UTF8Value,e1);
+      val(UTF8Key,e2);
+      result:=e1=e2;
+    end
+  else
+    Result := False;
+end;
+
 function CompInsensitiveWild(UTF8Value: PChar; const AnsiKey: String): Boolean;
 begin
   //IsWild does not work with UTF8 encoded strings for case insensitive searches,
@@ -1153,7 +1166,7 @@ begin
         end
         else
         begin
-          LocateFields[i].CompFunction := @CompSensitive;
+          LocateFields[i].CompFunction := @CompDouble;
           //get float types in appropriate format
           if VarIsArray(KeyValues) then
             Str(VarToDateTime(keyvalues[i]), AValue)