I have a problem: I have a datasnap / rest server, in it I have the following method:
Function TServerMethods.getComandoSQL(ASQL: string): TFDJSONDataSets;
begin
qryComando.Active := False;
qryComando.SQL.Clear;
qryComando.SQL.Add(ASQL);
Result := TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, qryComando);
end;
The method created by the client delphi itself:
function TServerMethodsClient.getComandoSQL(ASQL: string; const ARequestFilter: string): TFDJSONDataSets;
begin
if FgetComandoSQLCommand = nil then
begin
FgetComandoSQLCommand := FConnection.CreateCommand;
FgetComandoSQLCommand.RequestType := 'GET';
FgetComandoSQLCommand.Text := 'TServerMethods.getComandoSQL';
FgetComandoSQLCommand.Prepare(TServerMethods_getComandoSQL);
end;
FgetComandoSQLCommand.Parameters[0].Value.SetWideString(ASQL);
FgetComandoSQLCommand.Execute(ARequestFilter);
if not FgetComandoSQLCommand.Parameters[1].Value.IsNull then
begin
FUnMarshal := TDSRestCommand(FgetComandoSQLCommand.Parameters[1].ConnectionHandler).GetJSONUnMarshaler;
try
Result := TFDJSONDataSets(FUnMarshal.UnMarshal(FgetComandoSQLCommand.Parameters[1].Value.GetJSONValue(True)));
if FInstanceOwner then
FgetComandoSQLCommand.FreeOnExecute(Result);
finally
FreeAndNil(FUnMarshal)
end
end
else
Result := nil;
end;
When requesting this method from the client:
var
dataset: TFDJSONDataSets;
begin
dataset := DataModule1.ServerMethodsClient.getComandoSQL( _SQL )
self.AppendData( TFDJSONDataSetsReader.GetListValue(dataset, 0) );
end;
So far so good, the problem is when I send an sql of type: select code, description from table where description like '% AD%'
On the server: select code, description from table where description like '' % ''
This happens with AD, FA, FE among others ... if you enter for example% FAR% result is '' ZENDA% ''