Table editor: Apply default length/set for new columns as long as user didn't touch it. Fixes issue #2084.

This commit is contained in:
Ansgar Becker
2010-07-14 10:52:34 +00:00
parent 6a3e551d16
commit aad99190ae
3 changed files with 7 additions and 3 deletions

View File

@ -2226,6 +2226,7 @@ begin
Col.Name := rx.Match[1];
Col.OldName := Col.Name;
Col.Status := esUntouched;
Col.LengthCustomized := True;
// Datatype
Col.DataType := GetDatatypeByName(UpperCase(rx.Match[2]));

View File

@ -54,7 +54,7 @@ type
Name, OldName: String;
DataType: TDatatype;
LengthSet: String;
Unsigned, AllowNull, ZeroFill: Boolean;
Unsigned, AllowNull, ZeroFill, LengthCustomized: Boolean;
DefaultType: TColumnDefaultType;
DefaultText: String;
Comment, Collation: String;

View File

@ -1060,7 +1060,7 @@ begin
if not Col.DataType.HasLength then
Col.LengthSet := '';
// Suggest length/set if required
if Col.DataType.RequiresLength and (Col.LengthSet = '') then
if (not Col.LengthCustomized) or (Col.DataType.RequiresLength and (Col.LengthSet = '')) then
Col.LengthSet := Col.DataType.DefLengthSet;
// Auto-fix user selected default type which can be invalid now
case Col.DataType.Category of
@ -1085,7 +1085,10 @@ begin
end;
end; // Length / Set
3: Col.LengthSet := NewText;
3: begin
Col.LengthSet := NewText;
Col.LengthCustomized := True;
end;
// 4 + 5 are checkboxes - handled in OnClick
7: begin // Default value
Col.DefaultText := NewText;