You are not logged in.
Pages: 1
Hi, the following code (when running it as Admin) executes with no exceptions, but the AccessRights field is not updated from its default value:
  grp := TAuthGroup.CreateAndFillPrepare(MainForm.RestClient.Orm, 'ID=?', [3]);
  try
    if grp.FillOne then
    begin
      grp.SqlAccessRights.Edit(MainForm.RestClient.Model, TStatus,
              false, true, false, false);
      grp.SqlAccessRights.Edit(MainForm.RestClient.Model, TPerson,
              false, true, false, false);
      MainForm.RestClient.Update(grp);
    end;
  finally
    grp.Free
  end;why?
Offline
Well, since the connected account is Admin and no update to the AccessRights property of the AuthGroup object was made before the Rest db update action, I did a debug on the client side, and found the following:
The TOrmAccessRights record (not an object, indeed), did not preserve the GET, PUT, POST, DELETE arrays between the call of the Edit method and a call of the toString method. To testify this, the following workaround code works fine!
var
  grp: TAuthGroup;
  oar: TOrmAccessRights;
  ars: RawUTF8;
begin
  grp := TAuthGroup.CreateAndFillPrepare(MainForm.RestClient.Orm, 'ID=?', [3]);
  try
    if grp.FillOne then
    begin
      oar := grp.SqlAccessRights;
      oar.Edit(MainForm.RestClient.Model, TStatus, false, true, false, false);
      oar.Edit(MainForm.RestClient.Model, TPerson, false, true, false, false);
      FormatUtf8('%,%,%,%,%', [byte(oar.AllowRemoteExecute),
        GetBitCsv(oar.GET, MAX_TABLES), GetBitCsv(oar.POST, MAX_TABLES),
        GetBitCsv(oar.PUT, MAX_TABLES), GetBitCsv(oar.DELETE, MAX_TABLES)], ars);
      grp.AccessRights := ars;
      MainForm.RestClient.Update(grp);
    end;
  finally
    grp.Free
  end;
end;Offline
This is a compiler limitation.
I think you can just write:
      oar := grp.OrmAccessRights;
      oar.Edit(MainForm.RestClient.Model, TStatus, false, true, false, false);
      oar.Edit(MainForm.RestClient.Model, TPerson, false, true, false, false);
      grp.OrmAccessRights := oar;I have enhanced the documentation, and renamed SqlAccessRight as OrmAccessRight as it should be (in PUREMORMOT2 mode).
https://github.com/synopse/mORMot2/commit/73814dfd
Offline
Indeed @ab, you are right! Btw, the compiler is 32bit, Delphi XE.
Offline
Pages: 1