mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Drop default column value if user selects "No default". Fixes issue #2311.
This commit is contained in:
@ -364,6 +364,7 @@ var
|
|||||||
sql: String;
|
sql: String;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Specs: TStringList;
|
Specs: TStringList;
|
||||||
|
Col: TTableColumn;
|
||||||
begin
|
begin
|
||||||
// Create or alter table
|
// Create or alter table
|
||||||
Result := mrOk;
|
Result := mrOk;
|
||||||
@ -381,6 +382,13 @@ begin
|
|||||||
if FForeignKeys[i].Modified and (not FForeignKeys[i].Added) then
|
if FForeignKeys[i].Modified and (not FForeignKeys[i].Added) then
|
||||||
Specs.Add('DROP FOREIGN KEY '+QuoteIdent(FForeignKeys[i].OldKeyName));
|
Specs.Add('DROP FOREIGN KEY '+QuoteIdent(FForeignKeys[i].OldKeyName));
|
||||||
end;
|
end;
|
||||||
|
// Special case for removed default values on columns, which can neither be done in
|
||||||
|
// ALTER TABLE ... CHANGE COLUMN query, as there is no "no default" clause, nor by
|
||||||
|
// appending an ALTER COLUMN ... DROP DEFAULT, without getting an "unknown column" error
|
||||||
|
for Col in FColumns do begin
|
||||||
|
if (Col.FStatus = esModified) and (Col.DefaultType = cdtNothing) then
|
||||||
|
Specs.Add('ALTER '+QuoteIdent(Col.OldName)+' DROP DEFAULT');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
if Specs.Count > 0 then
|
if Specs.Count > 0 then
|
||||||
|
Reference in New Issue
Block a user