|
@@ -19,7 +19,7 @@ unit sqldbrestdata;
|
|
interface
|
|
interface
|
|
|
|
|
|
uses
|
|
uses
|
|
- Classes, SysUtils, sqldb, db, fpjson, sqldbrestio, sqldbrestschema;
|
|
|
|
|
|
+ Classes, SysUtils, bufdataset, sqldb, db, fpjson, sqldbrestio, sqldbrestschema;
|
|
|
|
|
|
Type
|
|
Type
|
|
TSQLQueryClass = Class of TSQLQuery;
|
|
TSQLQueryClass = Class of TSQLQuery;
|
|
@@ -49,12 +49,14 @@ Type
|
|
FStrings : TRestStringsConfig;
|
|
FStrings : TRestStringsConfig;
|
|
FResource : TSQLDBRestResource;
|
|
FResource : TSQLDBRestResource;
|
|
FOwnsResource : Boolean;
|
|
FOwnsResource : Boolean;
|
|
|
|
+ FUpdatedData: TBufDataset;
|
|
procedure CheckAllRequiredFieldsPresent;
|
|
procedure CheckAllRequiredFieldsPresent;
|
|
function GetAllowMultiUpdate: Boolean;
|
|
function GetAllowMultiUpdate: Boolean;
|
|
function GetCheckUpdateCount: Boolean;
|
|
function GetCheckUpdateCount: Boolean;
|
|
function GetUseLegacyPUT: Boolean;
|
|
function GetUseLegacyPUT: Boolean;
|
|
procedure SetExternalDataset(AValue: TDataset);
|
|
procedure SetExternalDataset(AValue: TDataset);
|
|
Protected
|
|
Protected
|
|
|
|
+ Procedure CreateUpdatedData(aSrc : TDataset);
|
|
function StreamRecord(O: TRestOutputStreamer; D: TDataset; FieldList: TRestFieldPairArray): Boolean; virtual;
|
|
function StreamRecord(O: TRestOutputStreamer; D: TDataset; FieldList: TRestFieldPairArray): Boolean; virtual;
|
|
function FindExistingRecord(D: TDataset): Boolean;
|
|
function FindExistingRecord(D: TDataset): Boolean;
|
|
function GetRequestFields: TSQLDBRestFieldArray;
|
|
function GetRequestFields: TSQLDBRestFieldArray;
|
|
@@ -110,7 +112,7 @@ Type
|
|
Property EmulateOffsetLimit : Boolean Read FEmulateOffsetLimit Write FEmulateOffsetLimit;
|
|
Property EmulateOffsetLimit : Boolean Read FEmulateOffsetLimit Write FEmulateOffsetLimit;
|
|
Property DeriveResourceFromDataset : Boolean Read FDeriveResourceFromDataset Write FDeriveResourceFromDataset;
|
|
Property DeriveResourceFromDataset : Boolean Read FDeriveResourceFromDataset Write FDeriveResourceFromDataset;
|
|
Property Options : TSQLDBRestDBHandlerOptions Read FOptions Write FOptions;
|
|
Property Options : TSQLDBRestDBHandlerOptions Read FOptions Write FOptions;
|
|
-
|
|
|
|
|
|
+ Property UpdatedData : TBufDataset Read FUpdatedData Write FUpdatedData;
|
|
end;
|
|
end;
|
|
TSQLDBRestDBHandlerClass = class of TSQLDBRestDBHandler;
|
|
TSQLDBRestDBHandlerClass = class of TSQLDBRestDBHandler;
|
|
|
|
|
|
@@ -655,6 +657,17 @@ begin
|
|
FExternalDataset.FreeNotification(Self);
|
|
FExternalDataset.FreeNotification(Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TSQLDBRestDBHandler.CreateUpdatedData(aSrc: TDataset);
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ if not Assigned(FUpdatedData) then
|
|
|
|
+ Exit;
|
|
|
|
+ aSrc.First;
|
|
|
|
+ FUpdatedData.CopyFromDataset(aSrc,True);
|
|
|
|
+ FUpdatedData.First;
|
|
|
|
+ aSrc.First;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TSQLDBRestDBHandler.SpecialResource: Boolean;
|
|
function TSQLDBRestDBHandler.SpecialResource: Boolean;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -930,10 +943,13 @@ begin
|
|
try
|
|
try
|
|
D.Open;
|
|
D.Open;
|
|
IO.RESTOutput.OutputOptions:=IO.RESTOutput.OutputOptions-[ooMetadata];
|
|
IO.RESTOutput.OutputOptions:=IO.RESTOutput.OutputOptions-[ooMetadata];
|
|
|
|
+ CreateUpdatedData(D);
|
|
StreamDataset(IO.RESTOutput,D,FieldList);
|
|
StreamDataset(IO.RESTOutput,D,FieldList);
|
|
finally
|
|
finally
|
|
D.Free;
|
|
D.Free;
|
|
end;
|
|
end;
|
|
|
|
+ if Assigned(UpdatedData) then
|
|
|
|
+ UpdatedData.First;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TSQLDBRestDBHandler.DoHandlePutPatch(IsPatch: Boolean);
|
|
procedure TSQLDBRestDBHandler.DoHandlePutPatch(IsPatch: Boolean);
|
|
@@ -966,10 +982,13 @@ begin
|
|
D.Open;
|
|
D.Open;
|
|
end;
|
|
end;
|
|
IO.RESTOutput.OutputOptions:=IO.RESTOutput.OutputOptions-[ooMetadata];
|
|
IO.RESTOutput.OutputOptions:=IO.RESTOutput.OutputOptions-[ooMetadata];
|
|
|
|
+ CreateUpdatedData(D);
|
|
StreamDataset(IO.RESTOutput,D,FieldList);
|
|
StreamDataset(IO.RESTOutput,D,FieldList);
|
|
finally
|
|
finally
|
|
D.Free;
|
|
D.Free;
|
|
end;
|
|
end;
|
|
|
|
+ if Assigned(UpdatedData) then
|
|
|
|
+ UpdatedData.First;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1139,6 +1158,8 @@ end;
|
|
|
|
|
|
destructor TSQLDBRestDBHandler.Destroy;
|
|
destructor TSQLDBRestDBHandler.Destroy;
|
|
begin
|
|
begin
|
|
|
|
+ if Assigned(FUpdatedData) and (FUpdatedData.Owner=Self) then
|
|
|
|
+ FreeAndNil(FUpdatedData);
|
|
FreeAndNil(FPostParams);
|
|
FreeAndNil(FPostParams);
|
|
If FOwnsResource then
|
|
If FOwnsResource then
|
|
FreeAndNil(FResource);
|
|
FreeAndNil(FResource);
|