Incomplete create constraint

Aurelius v5.3
I have a class Tfrmlines that includes:

    [Association([TAssociationProp.Required], CascadeTypeAll - [TCascadeType.Remove])]
    [JoinColumn('afmid', [TColumnProp.Required], 'afmid')]
    [JoinColumn('btid', [TColumnProp.Required], 'btid')]
    [JoinColumn('aa', [TColumnProp.Required], 'aa')]
    Ffrm: Tfrm;

During database update I am getting the following error:

EMySQLNativeException [FireDAC][Phys][MySQL] Can't create table pchr.#sql-19bc_48 (errno: 121 "Duplicate key on write or update")

The produced sql that causes the trouble during the database update is:

  FK_myformlines_myform_afmid_btid_aa FOREIGN KEY (afmid, btid, aa) REFERENCES myform (afmid, btid, aa)

I think that something like "ON UPDATE RESTRICT ON DELETE RESTRICT;" is missing, because adding it to the above sql statements it works

Some googling indicates you already have other foreign keys with that name in your database. Maybe your foreign key name is just too long, try make it shorter by using the ForeignKey attribute and explicitly providing a custom name.

1 Like

The big name of the constrain is finally the problem, you have right
This name FK_myformlines_myform_afmid_btid_aa is created by Aurelius (and it is even bigger in my case, the name of the tables are changed in this report)
The original size of the constraint name was 53 characters. With 52 characters this error is not produced

Thank you a lot

1 Like

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