Do we need this assert?

last version of Aurelius, file Aurelius.drivers.firedac, line 251:
Assert(Supports(Statement, IDBBatchStatement, BatchStatement));

Do we need this assert?
I lost my day yesterday to find the cause of an AV in the production version of a project....

Yes, it's needed. To invoke ExecuteBatch, the interface must implement IDBBatchStatement interface

Can you please then add a {$ASSERTIONS ON} in this unit for the following update?
Does this cause you any trouble somewhere else?

Sorry, can you please elaborate on what you need and what problem you want to solve, exactly? A 3rd party code should not force such directive. If you want to change it, just set it in your project options.

I need to have disabled the assertions in release versions of my software as I use them for debugging inside the code.
Till now, I had no problem with Aurelius and I started to get AV errors in a complex part of code when I started to use cacheUpdates. I finally arrived to this assert in this unit.
If I put a {$ASSERTIONS ON} this unit I have no noticeable problem/error and I can compile my software with assertions OFF in project options.
Assertions are not well advertised in Delphi but I use them as a habit. What do you propose?

I think you should send us a case to reproduce the problem. {$ASSERTIONS ON} will simply enable the assertions, which should be the case in Debug config, but not in Release config.

The problem I have till now exists in Release config with assertions off.
The problem is solved if {$ASSERTIONS ON} is put in Aurelius.drivers.firedac

Let's not discuss implementation. Let's discuss issues. Please provide a way to reproduce the issue so we can analyze the best way to solve it. Arbitrarily adding such directive is not a good solution.

1 Like

You can enable assertions in your Release config in project options.

I will try to create a project that simulates that but it seems to deal with the number of the data it waits to apply and I have no time these days. I will come back for this.

1 Like

Release compile asserts off in project options
Result: Exception

procedure Taureliusassert.Button1Click(Sender: TObject);
var
manager: TObjectManager;
n: Integer;
begin
lfd := Tmyfdbcon.connect(true);
manager := lfd.getobjman;
try
manager.BatchSize := 500;
manager.CachedUpdates := true;
for n := 0 to 5000 do
begin
var
psapo: Tapiprotosubst;
psapo := Tapiprotosubst.Create;
psapo.Id := n + 1;
psapo.protoid := Random(100000);
psapo.stepid := Random(100000);
manager.Save(psapo);
end;

manager.ApplyUpdates;

finally
manager.Free;
end;
end;

Mysql, table definition:

CREATE TABLE `testtable` (
	`id` INT(10) UNSIGNED NOT NULL,
	`protoid` INT(10) UNSIGNED NOT NULL,
	`stepid` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`substid` INT(10) UNSIGNED NOT NULL,
	`atc` VARCHAR(10) NOT NULL COLLATE 'utf8_general_ci',
	`descr` VARCHAR(250) NOT NULL COLLATE 'utf8_general_ci',
	`disp` VARCHAR(500) NOT NULL COLLATE 'utf8_general_ci',
	PRIMARY KEY (`id`) USING BTREE,
	INDEX `stepid` (`stepid`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
CHECKSUM=1;

Class:

  [Entity]
  [Table('testtable')]
  [Id('Fid', TIdGenerator.None)]
  Tapiprotosubst = class
  private
    [Column('id', [TColumnProp.Required])]
    Fid: Integer;
    [Column('protoid', [TColumnProp.Required])]
    Fprotoid: Integer;
    [Column('stepid', [TColumnProp.Required])]
    Fstepid: Integer;
    [Column('substid', [TColumnProp.Required])]
    Fsubstid: Integer;
    [Column('atc', [TColumnProp.Required], 10)]
    Fatc: string;
    [Column('descr', [TColumnProp.Required], 250)]
    Fdescr: string;
    [Column('disp', [TColumnProp.Required], 500)]
    Fdisp: string;
  public
    property Id: Integer read Fid write Fid;
    property protoid: Integer read Fprotoid write Fprotoid;
    property stepid: Integer read Fstepid write Fstepid;
    property substid: Integer read Fsubstid write Fsubstid;
    property atc: string read Fatc write Fatc;
    property descr: string read Fdescr write Fdescr;
    property disp: string read Fdisp write Fdisp;
  end;

Through IDE


Without IDE
εικόνα
Call stack and CPU

Can you please provide a sample project that reproduces the issue?

aurelius.zip (245.0 KB)

Thank you. The project is very helpful and speeds up the process. It was a bug and we fixed it here, regardless of assertions option. Next update will include the fix.

1 Like

Do you plan to circulate an update the following days? If not, can you send me a quick fix?

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

Yes, we will release an update next week.

1 Like