Skip to content

Commit

Permalink
insert except added
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoliy-savchak committed Feb 21, 2022
1 parent 9adfb75 commit c44eba4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
4 changes: 2 additions & 2 deletions SQL Format/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
6 changes: 3 additions & 3 deletions SQL Format/SQLFormat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationVersion>1.5.0.%2a</ApplicationVersion>
<ApplicationRevision>9</ApplicationRevision>
<ApplicationVersion>1.6.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -58,7 +58,7 @@
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.TransactSql.ScriptDom, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
Expand Down
44 changes: 43 additions & 1 deletion SQL Format/SQLTranslatorInsert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit c44eba4

Please sign in to comment.