Move code from helpers.GetColumnDefaultClause into dbconnection.TTableColumn.SQLCode. Support microseconds part in DEFAULT CURRENT_TIMESTAMP clause. Fixes issue #3506.

This commit is contained in:
Ansgar Becker
2014-03-09 04:08:12 +00:00
parent ccb5ed7d03
commit 906b80f3a5
3 changed files with 38 additions and 67 deletions

View File

@ -306,7 +306,6 @@ type
function StringListCompareAnythingDesc(List: TStringList; Index1, Index2: Integer): Integer;
function StringListCompareByValue(List: TStringList; Index1, Index2: Integer): Integer;
function GetColumnDefaultType(var Text: String): TColumnDefaultType;
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; DataTypeIndex: TDBDatatypeIndex; Text: String): String;
function GetImageLinkTimeStamp(const FileName: string): TDateTime;
function IsEmpty(Str: String): Boolean;
function IsNotEmpty(Str: String): Boolean;
@ -2148,25 +2147,6 @@ begin
end;
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; DataTypeIndex: TDBDatatypeIndex; Text: String): String;
begin
Text := esc(Text);
// Support BIT syntax in MySQL
if DataTypeIndex = dtBit then
Text := 'b'+Text;
case DefaultType of
cdtNothing: Result := '';
cdtText: Result := 'DEFAULT '+Text;
cdtTextUpdateTS: Result := 'DEFAULT '+Text+' ON UPDATE CURRENT_TIMESTAMP';
cdtNull: Result := 'DEFAULT NULL';
cdtNullUpdateTS: Result := 'DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP';
cdtCurTS: Result := 'DEFAULT CURRENT_TIMESTAMP';
cdtCurTSUpdateTS: Result := 'DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP';
cdtAutoInc: Result := 'AUTO_INCREMENT';
end;
end;
{**
Return compile date/time from passed .exe name
Code taken and modified from Michael Puff