Delphi 2010 + TDAMemdataTable + ZeosLib + PostgreSQL quotes problem

Hi,

We have a table linked to the TDAMemDataTable component throw TDARemoteDataAdapter, which is connected to the Application server built with Remobjects components connected to a PostgreSQL server with ZeosLib.

Our problem is that when we post a string containing simple quote is automatically replaced with \047. If we make the update with SQL statement, then it works.

//Delphi 2010 code, client side:
//First case, we use SQL way to update a record … It works …
var
x: TDAMemDataTable;

begin
x := TDAMemDataTable.Create(nil);
x.Name := ‘test’; // must give a name …
try
x.RemoteDataADapter := DM.RDA; // DataModule -> object, using as method SQLGetData !!!
x.LocalDataStreamer := DM.DS;

DM.RDA.GetDataCall.ParamByName('aSQLText').AsString := 'update <some_table> set <some_field> = ''<L''Oreal>'' where id = xxx';
DM.RDA.Fill([q], False, AIncludeSchema);

finally
FreeAndNil(q);
end;
end;

// Other case: we use TDAMemDataTable as phisical table … it’s wrong …
var
x: TDAMemDataTable;

begin
x := TDAMemDataTable.Create(nil);
x.Name := ‘test’; // must give a name …
x.TableName := ‘<SOME_TABLE_NAME>’;
try
x.RemoteDataADapter := DM.RDA_TABLES; // DataModule -> ANOTHER OBJECT, using as its method GetData !!!
x.LocalDataStreamer := DM.DS;

x.Open;
if x.Locate('<some_primary_key>', <APk_Value>, []) then
  try
    x.Edit;
    x.FieldByName('<some_field>').Value := <L'Oreal>;
    x.Post;
    if x.HasChanges then
      x.ApplyUpdates();

// At this point, we have: x.FieldByName(’<some_field>’).Value = <L\047Oreal> ???
// Also, instead of “” char, we have “\134” … :frowning:

  except
    raise;
  end;

finally
FreeAndNil(q);
end;
end;

I don’t recommend to use Local* properties of TDAMemDataTable because they were removed in DA8.
I can suggest to use it via LocalDataAdapter.

also Zeos lib quotes single quotes:

  // backslashes and single quotes must be escaped with backslashes
  function EscapeValue(AValue: String): String;
  begin
    Result := StringReplace(AValue, '\', '\\', [rfReplaceAll]);
    Result := StringReplace(Result, '''', '\''', [rfReplaceAll]);
  end;

so it can be a reason for such behavior.

Can you create a simple testcase that demonstrates this problems, pls?