mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-15 11:01:08 +08:00
Make views show their data again in data tab. Fixes issue #1515.
This commit is contained in:
@ -228,6 +228,7 @@ type
|
||||
function GetTableSize(Results: TMySQLQuery): Int64;
|
||||
function GetLightness(AColor: TColor): Byte;
|
||||
procedure ParseTableStructure(CreateTable: WideString; Columns: TObjectList=nil; Keys: TObjectList=nil; ForeignKeys: TObjectList=nil);
|
||||
procedure ParseViewStructure(ViewName: WideString; Columns: TObjectList);
|
||||
|
||||
var
|
||||
MainReg : TRegistry;
|
||||
@ -3126,6 +3127,33 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure ParseViewStructure(ViewName: WideString; Columns: TObjectList);
|
||||
var
|
||||
rx: TRegExpr;
|
||||
Col: TTableColumn;
|
||||
Results: TMySQLQuery;
|
||||
begin
|
||||
// Views reveal their columns only with a SHOW COLUMNS query.
|
||||
// No keys available in views - SHOW KEYS always returns an empty result
|
||||
Columns.Clear;
|
||||
rx := TRegExpr.Create;
|
||||
rx.Expression := '^(\w+)(\((.+)\))?';
|
||||
Results := Mainform.Connection.GetResults('SHOW COLUMNS FROM '+Mainform.mask(ViewName));
|
||||
while not Results.Eof do begin
|
||||
Col := TTableColumn.Create;
|
||||
Columns.Add(Col);
|
||||
Col.Name := Results.Col('Field');
|
||||
Col.AllowNull := Results.Col('Null') = 'YES';
|
||||
if rx.Exec(Results.Col('Type')) then begin
|
||||
Col.DataType := GetDatatypeByName(rx.Match[1]);
|
||||
Col.LengthSet := rx.Match[2];
|
||||
end;
|
||||
Results.Next;
|
||||
end;
|
||||
rx.Free;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ *** TTableColumn }
|
||||
|
||||
|
Reference in New Issue
Block a user