Skip to content

Commit 0fec887

Browse files
committed
fix: default name for new constraint too long for MySQL
Refs #2609
1 parent c123ccd commit 0fec887

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎source/table_editor.pas‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,6 +3118,7 @@ procedure TfrmTableEditor.listForeignKeysNewText(Sender: TBaseVirtualTree;
31183118
RefColumns: TTableColumnList;
31193119
TypesMatch: Boolean;
31203120
RefObj: TDBObject;
3121+
NewConstraintNameBase: String;
31213122
begin
31223123
// Cell text in foreign key list edited
31233124
Key := FForeignKeys[Node.Index];
@@ -3132,7 +3133,8 @@ procedure TfrmTableEditor.listForeignKeysNewText(Sender: TBaseVirtualTree;
31323133
2: begin
31333134
Key.ReferenceTable := NewText;
31343135
if not Key.KeyNameWasCustomized then begin
3135-
Key.KeyName := 'FK_'+editName.Text+'_'+Key.ReferenceTable;
3136+
NewConstraintNameBase := 'FK_' + Copy(editName.Text, 1, 25) + '_' + Copy(Key.ReferenceTable, 1, 25);
3137+
Key.KeyName := NewConstraintNameBase;
31363138
i := 1;
31373139
NameInUse := True;
31383140
while NameInUse do begin
@@ -3142,7 +3144,7 @@ procedure TfrmTableEditor.listForeignKeysNewText(Sender: TBaseVirtualTree;
31423144
end;
31433145
if NameInUse then begin
31443146
Inc(i);
3145-
Key.KeyName := 'FK_'+editName.Text+'_'+Key.ReferenceTable+'_'+IntToStr(i);
3147+
Key.KeyName := NewConstraintNameBase + '_' + IntToStr(i);
31463148
end;
31473149
end;
31483150

0 commit comments

Comments
 (0)