Issue #1853: try to fix column definition changes on MS SQL wrt collation quoting and default value

This commit is contained in:
Ansgar Becker
2025-05-16 14:44:38 +02:00
parent 3701c6054d
commit 686ef30fb4
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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]));