From f22fa996bab7ba1befcd4296f48c0fb64ec463fc Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 11 Feb 2010 23:26:37 +0000 Subject: [PATCH] Bulk table editor: No comma between charset + collation clause. Fixes issue #1685 --- source/tabletools.pas | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/source/tabletools.pas b/source/tabletools.pas index 138c0810..c0735d5f 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -1210,6 +1210,7 @@ var Specs, LogRow: TStringList; CreateView: String; rx: TRegExpr; + HasCharsetClause: Boolean; begin AddResults('SELECT '+esc(DBObj.Database)+' AS '+Mainform.mask('Database')+', ' + esc(DBObj.Name)+' AS '+Mainform.mask('Table')+', ' + @@ -1246,14 +1247,22 @@ begin else Specs.Add('ENGINE '+comboBulkTableEditEngine.Text); end; - if (DBObj.NodeType = lntTable) and chkBulkTableEditCollation.Checked and (comboBulkTableEditCollation.ItemIndex > -1) then - Specs.Add('COLLATE '+comboBulkTableEditCollation.Text); - if (DBObj.NodeType = lntTable) and chkBulkTableEditCharset.Checked and (comboBulkTableEditCharset.ItemIndex > -1) then begin - Mainform.Connection.CharsetTable.RecNo := comboBulkTableEditCharset.ItemIndex; - Specs.Add('CONVERT TO CHARSET '+Mainform.Connection.CharsetTable.Col('Charset')); + if DBObj.NodeType = lntTable then begin + HasCharsetClause := False; + if chkBulkTableEditCharset.Checked and (comboBulkTableEditCharset.ItemIndex > -1) then begin + Mainform.Connection.CharsetTable.RecNo := comboBulkTableEditCharset.ItemIndex; + Specs.Add('CONVERT TO CHARSET '+Mainform.Connection.CharsetTable.Col('Charset')); + HasCharsetClause := True; + end; + if chkBulkTableEditCollation.Checked and (comboBulkTableEditCollation.ItemIndex > -1) then begin + if HasCharsetClause then // No comma between charset + collation clause + Specs[Specs.Count-1] := Specs[Specs.Count-1] + ' COLLATE '+comboBulkTableEditCollation.Text + else + Specs.Add('COLLATE '+comboBulkTableEditCollation.Text); + end; + if chkBulkTableEditResetAutoinc.Checked then + Specs.Add('AUTO_INCREMENT=0'); end; - if (DBObj.NodeType = lntTable) and chkBulkTableEditResetAutoinc.Checked then - Specs.Add('AUTO_INCREMENT=0'); LogRow := TStringList(FResults.Last); if Specs.Count > 0 then begin