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;
|
function TTableColumn.SQLCode(OverrideCollation: String=''; Parts: TColumnParts=[cpAll]): String;
|
||||||
var
|
var
|
||||||
IsVirtual: Boolean;
|
IsVirtual: Boolean;
|
||||||
|
QuoteCollation: Boolean;
|
||||||
|
|
||||||
function InParts(Part: TColumnPart): Boolean;
|
function InParts(Part: TColumnPart): Boolean;
|
||||||
begin
|
begin
|
||||||
@ -10941,7 +10942,7 @@ begin
|
|||||||
Result := Result + 'INVISIBLE ';
|
Result := Result + 'INVISIBLE ';
|
||||||
end;
|
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
|
if not AllowNull then
|
||||||
Result := Result + 'NOT NULL '
|
Result := Result + 'NOT NULL '
|
||||||
else if not FConnection.Parameters.IsAnyInterbase then
|
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 InParts(cpCollation) and (not IsVirtual) and (DataType.Index <> dbdtJson) then begin
|
||||||
if Collation <> '' then begin
|
if Collation <> '' then begin
|
||||||
Result := Result + 'COLLATE ';
|
Result := Result + 'COLLATE ';
|
||||||
|
QuoteCollation := not FConnection.Parameters.IsAnyMSSQL;
|
||||||
if OverrideCollation <> '' then
|
if OverrideCollation <> '' then
|
||||||
Result := Result + FConnection.EscapeString(OverrideCollation) + ' '
|
Result := Result + IfThen(QuoteCollation, FConnection.EscapeString(OverrideCollation), OverrideCollation) + ' '
|
||||||
else
|
else
|
||||||
Result := Result + FConnection.EscapeString(Collation) + ' ';
|
Result := Result + IfThen(QuoteCollation, FConnection.EscapeString(Collation), Collation) + ' ';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ begin
|
|||||||
ColSpec := Col.SQLCode(OverrideCollation);
|
ColSpec := Col.SQLCode(OverrideCollation);
|
||||||
case Col.Status of
|
case Col.Status of
|
||||||
esModified: begin
|
esModified: begin
|
||||||
Specs.Add(Format(AlterColBase, [Conn.QuoteIdent(Col.OldName), ColSpec]));
|
Specs.Add(Format(AlterColBase, ['', ColSpec]));
|
||||||
end;
|
end;
|
||||||
esAddedUntouched, esAddedModified: begin
|
esAddedUntouched, esAddedModified: begin
|
||||||
Specs.Add(Format(AddColBase, [ColSpec]));
|
Specs.Add(Format(AddColBase, [ColSpec]));
|
||||||
|
Reference in New Issue
Block a user