From c44eba4c38014cf3b4f8aec269d35eb406a1f0e1 Mon Sep 17 00:00:00 2001 From: anatoliy_savchak Date: Mon, 21 Feb 2022 15:08:26 +0200 Subject: [PATCH] insert except added --- SQL Format/Properties/AssemblyInfo.cs | 4 +-- SQL Format/SQLFormat.csproj | 6 ++-- SQL Format/SQLTranslatorInsert.cs | 44 ++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/SQL Format/Properties/AssemblyInfo.cs b/SQL Format/Properties/AssemblyInfo.cs index 6f092b5..490722c 100644 --- a/SQL Format/Properties/AssemblyInfo.cs +++ b/SQL Format/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/SQL Format/SQLFormat.csproj b/SQL Format/SQLFormat.csproj index d4b6013..63312c8 100644 --- a/SQL Format/SQLFormat.csproj +++ b/SQL Format/SQLFormat.csproj @@ -23,8 +23,8 @@ false false true - 7 - 1.5.0.%2a + 9 + 1.6.0.%2a false true true @@ -58,7 +58,7 @@ true - true + false diff --git a/SQL Format/SQLTranslatorInsert.cs b/SQL Format/SQLTranslatorInsert.cs index 9102548..2978ee6 100644 --- a/SQL Format/SQLTranslatorInsert.cs +++ b/SQL Format/SQLTranslatorInsert.cs @@ -94,7 +94,16 @@ public override void SetupOptionsContent(Control Parent, EventHandler changedHan checkBox.CheckedChanged += changedHandler; Parent.Controls.Add(checkBox); } - + + { + CheckBox checkBox = new CheckBox(); + checkBox.Text = "except"; + checkBox.Name = "option_except"; + checkBox.Checked = false; + checkBox.CheckedChanged += changedHandler; + Parent.Controls.Add(checkBox); + } + } public override string TranslateExt(CreateTableStatement createTableStatement, object options) @@ -171,6 +180,16 @@ public override string TranslateExt(CreateTableStatement createTableStatement, o } } + bool bExcept = false; + if (options is Control) + { + var r = ((Control)options).Controls.Find("option_except", true); + if (r.Length > 0) + { + bExcept = (r[0] as CheckBox).Checked; + } + } + string keywordSep = bOptionInline ? " " : Environment.NewLine; string optionAllias = optionAllias0; string optionAlliasDest = optionAlliasDest0; @@ -254,6 +273,29 @@ public override string TranslateExt(CreateTableStatement createTableStatement, o result.Append($")"); } + if (bExcept) + { + result.Append($"except{Environment.NewLine}"); + result.Append($"select{keywordSep}"); + sep = null; + foreach (ColumnDefinition columnDefinition in tableDefinition.ColumnDefinitions) + { + if (!bOptionDefault && TSQLHelper.ColumnIsDefault(columnDefinition)) continue; + string ident = TSQLHelper.Identifier2Value(columnDefinition.ColumnIdentifier); + if (bOptionExplicitNames) + { + result.Append($"{columnIdent}{sep}{ident} = {optionAllias}{ident}{sColumnSeparator}"); + } + else + { + result.Append($"{columnIdent}{sep}{optionAllias}{ident}{sColumnSeparator}"); + } + if (String.IsNullOrEmpty(sep)) sep = ", "; + } + + result.Append($"{keywordSep}from {optionAllias0}{Environment.NewLine}"); + } + result.Append($";"); return result.ToString(); }