mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Detect DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP in column definitions. See http://www.heidisql.com/forum.php?t=15768
This commit is contained in:
@ -4209,22 +4209,25 @@ begin
|
||||
// Default value
|
||||
Col.DefaultType := cdtNothing;
|
||||
Col.DefaultText := '';
|
||||
rxCol.Expression := 'CURRENT_TIMESTAMP(\(\d+\))?(\s+ON\s+UPDATE\s+CURRENT_TIMESTAMP(\(\d+\))?)?';
|
||||
rxCol.Expression := '(NULL|CURRENT_TIMESTAMP(\(\d+\))?)(\s+ON\s+UPDATE\s+CURRENT_TIMESTAMP(\(\d+\))?)?';
|
||||
if UpperCase(Copy(ColSpec, 1, 14)) = 'AUTO_INCREMENT' then begin
|
||||
Col.DefaultType := cdtAutoInc;
|
||||
Col.DefaultText := 'AUTO_INCREMENT';
|
||||
Delete(ColSpec, 1, 15);
|
||||
end else if UpperCase(Copy(ColSpec, 1, 8)) = 'DEFAULT ' then begin
|
||||
Delete(ColSpec, 1, 8);
|
||||
if UpperCase(Copy(ColSpec, 1, 4)) = 'NULL' then begin
|
||||
Col.DefaultType := cdtNull;
|
||||
Col.DefaultText := 'NULL';
|
||||
Delete(ColSpec, 1, 5);
|
||||
end else if rxCol.Exec(ColSpec) then begin
|
||||
Col.DefaultType := cdtCurTS;
|
||||
Col.DefaultText := 'CURRENT_TIMESTAMP';
|
||||
if rxCol.Match[2] <> '' then
|
||||
Col.DefaultType := cdtCurTSUpdateTS;
|
||||
if rxCol.Exec(ColSpec) then begin
|
||||
if rxCol.Match[1] = 'NULL' then begin
|
||||
Col.DefaultType := cdtNull;
|
||||
Col.DefaultText := 'NULL';
|
||||
if rxCol.Match[3] <> '' then
|
||||
Col.DefaultType := cdtNullUpdateTS;
|
||||
end else begin
|
||||
Col.DefaultType := cdtCurTS;
|
||||
Col.DefaultText := 'CURRENT_TIMESTAMP';
|
||||
if rxCol.Match[3] <> '' then
|
||||
Col.DefaultType := cdtCurTSUpdateTS;
|
||||
end;
|
||||
Delete(ColSpec, 1, rxCol.MatchLen[0]);
|
||||
end else if (ColSpec[1] = '''') or (Copy(ColSpec, 1, 2) = 'b''') then begin
|
||||
InLiteral := True;
|
||||
|
Reference in New Issue
Block a user