mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Fix recently broken support for views in "Copy table" dialog.
This commit is contained in:
@@ -121,15 +121,24 @@ begin
|
||||
if comboDatabase.ItemIndex = -1 then
|
||||
comboDatabase.ItemIndex := 0;
|
||||
|
||||
CreateCode := MainForm.Connection.GetVar('SHOW CREATE TABLE '+MainForm.mask(FDBObj.Name), 1);
|
||||
// Fetch columns and key structures from table or view
|
||||
FColumns.Clear;
|
||||
FKeys.Clear;
|
||||
FForeignKeys.Clear;
|
||||
ParseTableStructure(CreateCode, FColumns, FKeys, FForeignKeys);
|
||||
case FDBObj.NodeType of
|
||||
lntTable: begin
|
||||
CreateCode := MainForm.Connection.GetVar('SHOW CREATE TABLE '+MainForm.mask(FDBObj.Name), 1);
|
||||
ParseTableStructure(CreateCode, FColumns, FKeys, FForeignKeys);
|
||||
end;
|
||||
lntView: ParseViewStructure(FDBObj.Name, FColumns);
|
||||
else raise Exception.Create('Neither table nor view: '+FDBObj.Name);
|
||||
end;
|
||||
|
||||
// Reset options tree
|
||||
TreeElements.Clear;
|
||||
TreeElements.RootNodeCount := 4;
|
||||
|
||||
// Load recent WHERE clauses from registry into dropdown menu
|
||||
popupRecentFilters.Items.Clear;
|
||||
OpenRegistry;
|
||||
Values := TStringList.Create;
|
||||
|
||||
@@ -2696,7 +2696,7 @@ begin
|
||||
Columns.Clear;
|
||||
rx := TRegExpr.Create;
|
||||
rx.Expression := '^(\w+)(\((.+)\))?';
|
||||
Results := Mainform.Connection.GetResults('SHOW COLUMNS FROM '+Mainform.mask(ViewName));
|
||||
Results := Mainform.Connection.GetResults('SHOW /*!32332 FULL */ COLUMNS FROM '+Mainform.mask(ViewName));
|
||||
while not Results.Eof do begin
|
||||
Col := TTableColumn.Create;
|
||||
Columns.Add(Col);
|
||||
@@ -2706,6 +2706,20 @@ begin
|
||||
Col.DataType := GetDatatypeByName(rx.Match[1]);
|
||||
Col.LengthSet := rx.Match[3];
|
||||
end;
|
||||
Col.Unsigned := (Col.DataType.Category = dtcInteger) and (Pos('unsigned', Results.Col('Type')) > 0);
|
||||
Col.AllowNull := UpperCase(Results.Col('Null')) = 'YES';
|
||||
Col.Collation := Results.Col('Collation', True);
|
||||
Col.Comment := Results.Col('Comment', True);
|
||||
if Col.DataType.Category <> dtcTemporal then
|
||||
Col.DefaultText := Results.Col('Default');
|
||||
if Results.IsNull('Default') and Col.AllowNull then
|
||||
Col.DefaultType := cdtNull
|
||||
else if Col.DataType.Index = dtTimestamp then
|
||||
Col.DefaultType := cdtCurTSUpdateTS
|
||||
else if (Col.DefaultText = '') and Col.AllowNull then
|
||||
Col.DefaultType := cdtNothing
|
||||
else
|
||||
Col.DefaultType := cdtText;
|
||||
Results.Next;
|
||||
end;
|
||||
rx.Free;
|
||||
|
||||
Reference in New Issue
Block a user