Browse Source

* Revert undesired changes introduced in last commit

git-svn-id: trunk@30928 -
blikblum 10 years ago
parent
commit
e8175ed0cf
1 changed files with 26 additions and 26 deletions
  1. 26 26
      packages/fcl-db/src/sqlite/customsqliteds.pas

+ 26 - 26
packages/fcl-db/src/sqlite/customsqliteds.pas

@@ -759,10 +759,7 @@ begin
   case GetMode of
   case GetMode of
     gmPrior:
     gmPrior:
       if (FCurrentItem^.Previous = FBeginItem) or (FCurrentItem = FBeginItem) then
       if (FCurrentItem^.Previous = FBeginItem) or (FCurrentItem = FBeginItem) then
-      begin
-        Result := grBOF;
-        FCurrentItem := FBeginItem;
-      end
+        Result := grBOF
       else
       else
         FCurrentItem:=FCurrentItem^.Previous;
         FCurrentItem:=FCurrentItem^.Previous;
     gmCurrent:
     gmCurrent:
@@ -888,14 +885,16 @@ var
 begin
 begin
   Dec(FRecordCount);
   Dec(FRecordCount);
   TempItem := PPDataRecord(ActiveBuffer)^;
   TempItem := PPDataRecord(ActiveBuffer)^;
+  if TempItem = FCacheItem then // Record is being edited
+    TempItem := FInternalActiveBuffer;
   TempItem^.Next^.Previous := TempItem^.Previous;
   TempItem^.Next^.Previous := TempItem^.Previous;
   TempItem^.Previous^.Next := TempItem^.Next;
   TempItem^.Previous^.Next := TempItem^.Next;
   if FCurrentItem = TempItem then
   if FCurrentItem = TempItem then
   begin
   begin
-    if FCurrentItem^.Previous <> FBeginItem then
-      FCurrentItem := FCurrentItem^.Previous
+    if FCurrentItem^.Next <> FEndItem then
+      FCurrentItem := FCurrentItem^.Next
     else
     else
-      FCurrentItem := FCurrentItem^.Next;  
+      FCurrentItem := FCurrentItem^.Previous;  
   end; 
   end; 
   // Dec FNextAutoInc (only if deleted item is the last record)  
   // Dec FNextAutoInc (only if deleted item is the last record)  
   if FAutoIncFieldNo <> -1 then
   if FAutoIncFieldNo <> -1 then
@@ -1427,39 +1426,40 @@ begin
   end;
   end;
 end;
 end;
 
 
-// Specific functions 
+// Specific functions
 
 
-procedure TCustomSqliteDataset.SetDetailFilter;
-  function FieldToSqlStr(AField: TField): String;
+function GetFieldEqualExpression(AField: TField): String;
+begin
+  if not AField.IsNull then
   begin
   begin
-    if not AField.IsNull then
-    begin
-      case AField.DataType of
-        //todo: handle " caracter properly
-        ftString, ftMemo:
-          Result := '"' + AField.AsString + '"';
-        ftDateTime, ftDate, ftTime:
-          Str(AField.AsDateTime, Result);
-      else
-        Result := AField.AsString;
-      end; //case
-    end
+    case AField.DataType of
+      //todo: handle " caracter properly
+      ftString, ftMemo:
+        Result := '"' + AField.AsString + '"';
+      ftDateTime, ftDate, ftTime:
+        Str(AField.AsDateTime, Result);
     else
     else
-      Result:=NullString;
-  end; //function
+      Result := AField.AsString;
+    end; //case
+    Result := ' = ' + Result;
+  end
+  else
+    Result := ' IS NULL';
+end;
 
 
+procedure TCustomSqliteDataset.SetDetailFilter;
 var
 var
   AFilter: String;
   AFilter: String;
   i: Integer;
   i: Integer;
 begin
 begin
-  if not FMasterLink.Active or (FMasterLink.Dataset.RecordCount = 0) then //Retrieve all data
+  if not FMasterLink.Active then //Retrieve all data
     FEffectiveSQL := FSqlFilterTemplate
     FEffectiveSQL := FSqlFilterTemplate
   else
   else
   begin
   begin
     AFilter := ' where ';
     AFilter := ' where ';
     for i := 0 to FMasterLink.Fields.Count - 1 do
     for i := 0 to FMasterLink.Fields.Count - 1 do
     begin
     begin
-      AFilter := AFilter + IndexFields[i].FieldName + ' = ' + FieldToSqlStr(TField(FMasterLink.Fields[i]));
+      AFilter := AFilter + IndexFields[i].FieldName + GetFieldEqualExpression(TField(FMasterLink.Fields[i]));
       if i <> FMasterLink.Fields.Count - 1 then
       if i <> FMasterLink.Fields.Count - 1 then
         AFilter := AFilter + ' and ';
         AFilter := AFilter + ' and ';
     end;
     end;