You are not logged in.
Pages: 1
Hi Ab
I am currently trying to fill a table with data, serverside.
I get access to the "current" rest server using this method:
function TLCSSimulationImpl.GetSQLRest: TSQLRest; // getter for SQLRest property
begin
if Assigned(ServiceContext.Factory)
then Result:=ServiceContext.Factory.RestServer
else Result:=nil;
if Result=nil then
raise ELCSSimulationFatal.CreateFmt('%s.GetSQLRest - Restserver not available',[ClassName]);
end;
And I would like to update my blob fields the same way it is accomplished using TSQLRestCLient.UpdateBlobfields, but unfortunately the UpdateBlobFields nor the RetrieveBlobFields methid is implemented in the TSQLRest base class...
...
SQLRest.UpdateBlobFields(Rec);
...
Will this be implemented soon, or should I look for a different solution?
regards - hans
Offline
For intermediate I have created this helper class to get around it. Unfortunately I had to copy GetLongStrProp and GetLongStrProp from mormot.pas into my own unit, as they were not declared in the interface section.
I strongly suggest UpdateBlobFields and RetrieveBlobfields to be added to TSQLRest as virtual (abstract?) methods so they will be available on both server and client side.
type
TSQLRestBlobHelper=class helper for TSQLRest
public
function UpdateBlobFields(Value: TSQLRecord): boolean;
function RetrieveBlobFields(Value: TSQLRecord): boolean;
end;
...
function TSQLRestBlobHelper.RetrieveBlobFields(Value: TSQLRecord): boolean;
var BlobData: TSQLRawBlob;
i: integer;
begin
result := false;
if (Self=nil) or (Value=nil) or (Value.ID<=0) then
exit;
result := True;
with Value.RecordProps do
if BlobFields<>nil then
for i := 0 to high(BlobFields) do
begin
Result:=Result and RetrieveBlob(TSQLRecordClass(Value.Classtype),Value.ID,BlobFields[i].Name,BlobData);
if Result then
SetLongStrProp(Value,BlobFields[i].PropInfo,BlobData)
else Exit;
end;
result := true;
end;
function TSQLRestBlobHelper.UpdateBlobFields(Value: TSQLRecord): boolean;
var BlobData: RawByteString;
i: integer;
begin
result := false;
if (Self=nil) or (Value=nil) or (Value.ID<=0) then
exit;
result := True;
with Value.RecordProps do
if BlobFields<>nil then
for i := 0 to high(BlobFields) do
begin
GetLongStrProp(Value,BlobFields[i].PropInfo,BlobData);
Result:=Result and UpdateBlob(TSQLRecordClass(Value.Classtype),Value.ID,BlobFields[i].Name,BlobData);
if not result then
exit;
end;
end;
Offline
Offline
It's done for UpdateBlobFields() and RetrieveBlobFields() methods, with optimized overriden implementations
See http://synopse.info/fossil/info/5f90c760e2 and http://synopse.info/fossil/info/6a260c2e19
It was a bit more complicated than you guessed, since I wanted to implement some direct overriden methods, with much more optimized data access (to minimize data conversion or transfert, and use a single SQL request on server side).
Online
Yay!
Offline
Pages: 1