#1 2022-04-04 20:04:22

tbo
Member
Registered: 2015-04-20
Posts: 353

Problems with Delete and TRecordVersion

Delphi 11.1, mORMot commit 2d598b6

When I want to delete multiple ORM objects that have a RecordVersion property, I get an exception (ExceptionMessage = EOrmBatchException: TRestBatch "i" with TOrmTableDeleted whereas expects TOrmTest). Single deletion works. The following example shows the problem:

program MultiDelete;
{$APPTYPE CONSOLE}

uses
  {$I mormot.uses.inc}
  System.SysUtils, mormot.core.base, mormot.core.unicode, mormot.orm.base, mormot.orm.core, mormot.rest.sqlite3, mormot.db.raw.sqlite3.static;

type
  TOrmTest = class(TOrm)
  private
    FRecVersion: TRecordVersion;
  published
    property RecVersion: TRecordVersion read FRecVersion;
  end;

procedure Main;
var
  i: Integer;
  item: TOrmTest;
  restServer: TRestServerDB;
begin
  restServer := TRestServerDB.CreateWithOwnModel([TOrmTest], ChangeFileExt(ParamStr(0), '.dat'));
  try
    restServer.CreateMissingTables;

    item := TOrmTest.Create;
    try
      for i := 1 to 10 do
        restServer.Add(item, True);
    finally item.Free; end;

    restServer.Server.Delete(TOrmTest, 'RowID>?', [2]);
  finally restServer.Free; end;
end;

begin
  try
    Main;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  ReadLn;
end.

With best regards
Thomas

Offline

#2 2022-04-06 07:40:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Problems with Delete and TRecordVersion

You are right.

It should be fixed by https://github.com/synopse/mORMot2/commit/0455b964

It was also affecting mORMot 1 - I fix it for it too.

Offline

Board footer

Powered by FluxBB