Drop default column value if user selects "No default". Fixes issue #2311.

This commit is contained in:
Ansgar Becker
2011-02-16 19:46:03 +00:00
parent 72f71bd845
commit 06ae6b9c8c

View File

@ -364,6 +364,7 @@ var
sql: String;
i: Integer;
Specs: TStringList;
Col: TTableColumn;
begin
// Create or alter table
Result := mrOk;
@ -381,6 +382,13 @@ begin
if FForeignKeys[i].Modified and (not FForeignKeys[i].Added) then
Specs.Add('DROP FOREIGN KEY '+QuoteIdent(FForeignKeys[i].OldKeyName));
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;
try
if Specs.Count > 0 then