mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Set explicit default value "NO ACTION" for ON UPDATE/DELETE clauses when creating a foreign key. Closes #1320
This commit is contained in:
@ -9537,6 +9537,9 @@ begin
|
|||||||
Columns.StrictDelimiter := True;
|
Columns.StrictDelimiter := True;
|
||||||
ForeignColumns := TStringList.Create;
|
ForeignColumns := TStringList.Create;
|
||||||
ForeignColumns.StrictDelimiter := True;
|
ForeignColumns.StrictDelimiter := True;
|
||||||
|
// Explicit default action required, since MariaDB and MySQL have different defaults if it's left away, see issue #1320
|
||||||
|
OnUpdate := 'NO ACTION';
|
||||||
|
OnDelete := 'NO ACTION';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TForeignKey.Destroy;
|
destructor TForeignKey.Destroy;
|
||||||
|
@ -2468,8 +2468,6 @@ begin
|
|||||||
Key := TForeignKey.Create(DBObject.Connection);
|
Key := TForeignKey.Create(DBObject.Connection);
|
||||||
idx := FForeignKeys.Add(Key);
|
idx := FForeignKeys.Add(Key);
|
||||||
Key.KeyName := 'FK'+IntToStr(idx+1);
|
Key.KeyName := 'FK'+IntToStr(idx+1);
|
||||||
Key.OnUpdate := '';
|
|
||||||
Key.OnDelete := '';
|
|
||||||
Key.Added := True;
|
Key.Added := True;
|
||||||
Modification(Sender);
|
Modification(Sender);
|
||||||
listForeignKeys.Repaint;
|
listForeignKeys.Repaint;
|
||||||
@ -2647,14 +2645,9 @@ begin
|
|||||||
4: begin
|
4: begin
|
||||||
CellText := Key.OnUpdate;
|
CellText := Key.OnUpdate;
|
||||||
// Both ON UPDATE + DELETE default to "RESTRICT", see http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
|
// Both ON UPDATE + DELETE default to "RESTRICT", see http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
|
||||||
if CellText = '' then
|
// MySQL 8 has a "NO ACTION" default here, which makes any fallback wrong here
|
||||||
CellText := 'RESTRICT';
|
|
||||||
end;
|
|
||||||
5: begin
|
|
||||||
CellText := Key.OnDelete;
|
|
||||||
if CellText = '' then
|
|
||||||
CellText := 'RESTRICT';
|
|
||||||
end;
|
end;
|
||||||
|
5: CellText := Key.OnDelete;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user