From a8ddb4da7e50bc133ed4e83ca455c0a72895053b Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 7 Oct 2025 20:56:30 +0200 Subject: [PATCH] Issue #2266: move INVISIBLE clause for MySQL/MariaDB table columns after the virtual and generation clause --- source/dbconnection.pas | 16 +++++++++------- source/grideditlinks.pas | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 47a6dd2d..ad4ee097 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -10788,6 +10788,7 @@ end; function TTableColumn.SQLCode(OverrideCollation: String=''; Parts: TColumnParts=[cpAll]): String; var IsVirtual: Boolean; + QuoteCollation: Boolean; function InParts(Part: TColumnPart): Boolean; begin @@ -10823,11 +10824,7 @@ begin Result := Result + ' '; // Add space after each part end; - if InParts(cpInvisible) and Invisible and FConnection.Has(frInvisibleColumns) then 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 @@ -10876,6 +10873,10 @@ begin Result := Result + 'AS ('+GenerationExpression+') ' + Virtuality + ' '; end; + if InParts(cpInvisible) and Invisible and FConnection.Has(frInvisibleColumns) then begin + Result := Result + 'INVISIBLE '; + end; + if InParts(cpComment) then begin if (Comment <> '') and FConnection.Parameters.IsAnyMySQL then Result := Result + 'COMMENT ' + FConnection.EscapeString(Comment) + ' '; @@ -10884,10 +10885,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; diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index 5304d066..693d7ffe 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -940,7 +940,7 @@ var NewText: String; begin if AllowCustomText and FAllowEdit then begin - if (not ItemMustExist) or ValueList.Contains(FCombo.Text) then + if (not ItemMustExist) or (ValueList.IndexOf(FCombo.Text)>-1) then NewText := FCombo.Text else NewText := '';