diff --git a/source/table_editor.pas b/source/table_editor.pas index 210d1be4..2f95d88d 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -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