mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #1853: try to fix column definition changes on MS SQL wrt collation quoting and default value
This commit is contained in:
@ -10904,6 +10904,7 @@ end;
|
||||
function TTableColumn.SQLCode(OverrideCollation: String=''; Parts: TColumnParts=[cpAll]): String;
|
||||
var
|
||||
IsVirtual: Boolean;
|
||||
QuoteCollation: Boolean;
|
||||
|
||||
function InParts(Part: TColumnPart): Boolean;
|
||||
begin
|
||||
@ -10941,7 +10942,7 @@ begin
|
||||
Result := Result + 'INVISIBLE ';
|
||||
end;
|
||||
|
||||
if InParts(cpAllowNull) and (not IsVirtual) then begin
|
||||
if InParts(cpAllowNull) and (not IsVirtual) and (not FConnection.Parameters.IsAnyMSSQL) then begin
|
||||
if not AllowNull then
|
||||
Result := Result + 'NOT NULL '
|
||||
else if not FConnection.Parameters.IsAnyInterbase then
|
||||
@ -10998,10 +10999,11 @@ begin
|
||||
if InParts(cpCollation) and (not IsVirtual) and (DataType.Index <> dbdtJson) then begin
|
||||
if Collation <> '' then begin
|
||||
Result := Result + 'COLLATE ';
|
||||
QuoteCollation := not FConnection.Parameters.IsAnyMSSQL;
|
||||
if OverrideCollation <> '' then
|
||||
Result := Result + FConnection.EscapeString(OverrideCollation) + ' '
|
||||
Result := Result + IfThen(QuoteCollation, FConnection.EscapeString(OverrideCollation), OverrideCollation) + ' '
|
||||
else
|
||||
Result := Result + FConnection.EscapeString(Collation) + ' ';
|
||||
Result := Result + IfThen(QuoteCollation, FConnection.EscapeString(Collation), Collation) + ' ';
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -725,7 +725,7 @@ begin
|
||||
ColSpec := Col.SQLCode(OverrideCollation);
|
||||
case Col.Status of
|
||||
esModified: begin
|
||||
Specs.Add(Format(AlterColBase, [Conn.QuoteIdent(Col.OldName), ColSpec]));
|
||||
Specs.Add(Format(AlterColBase, ['', ColSpec]));
|
||||
end;
|
||||
esAddedUntouched, esAddedModified: begin
|
||||
Specs.Add(Format(AddColBase, [ColSpec]));
|
||||
|
Reference in New Issue
Block a user