Skip to content

Commit

Permalink
V2.1.1 (#31)
Browse files Browse the repository at this point in the history
* N prefix SQL Server strings.

* Add WriteScriptHelp method to enable external usage.
  • Loading branch information
chullybun committed Dec 15, 2022
1 parent c6c75d3 commit 3f242e0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Represents the **NuGet** versions.

## v2.1.1
- *Fixed:* Multibyte support added to the `DataParser` insert and merge for SQL Server strings using the `N` prefix.

## v2.1.0
- *Enhancement:* Added `DataParserArgs.ColumnDefaults` so that _any_ table column(s) can be defaulted where required (where not directly specified).
- *Enhancement:* Improved help text to include the schema command and arguments.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
10 changes: 9 additions & 1 deletion src/DbEx.MySql/Console/MySqlMigrationConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ public sealed class MySqlMigrationConsole : MigrationConsoleBase<MySqlMigrationC
protected override void OnWriteHelp()
{
base.OnWriteHelp();
WriteScriptHelp();
Logger?.LogInformation("{help}", string.Empty);
}

/// <summary>
/// Writes the supported <see cref="MigrationCommand.Script"/> help content.
/// </summary>
public void WriteScriptHelp()
{
Logger?.LogInformation("{help}", "Script command and argument(s):");
Logger?.LogInformation("{help}", " script [default] Creates a default (empty) SQL script.");
Logger?.LogInformation("{help}", " script alter <table> Creates a SQL script to perform an ALTER TABLE.");
Logger?.LogInformation("{help}", " script create <table> Creates a SQL script to perform a CREATE TABLE.");
Logger?.LogInformation("{help}", " script refdata <table> Creates a SQL script to perform a CREATE TABLE as reference data.");
Logger?.LogInformation("{help}", string.Empty);
}
}
}
10 changes: 9 additions & 1 deletion src/DbEx.SqlServer/Console/SqlServerMigrationConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public sealed class SqlServerMigrationConsole : MigrationConsoleBase<SqlServerMi
protected override void OnWriteHelp()
{
base.OnWriteHelp();
WriteScriptHelp();
Logger?.LogInformation("{help}", string.Empty);
}

/// <summary>
/// Writes the supported <see cref="MigrationCommand.Script"/> help content.
/// </summary>
public void WriteScriptHelp()
{
Logger?.LogInformation("{help}", "Script command and argument(s):");
Logger?.LogInformation("{help}", " script [default] Creates a default (empty) SQL script.");
Logger?.LogInformation("{help}", " script alter <Schema> <Table> Creates a SQL script to perform an ALTER TABLE.");
Expand All @@ -57,7 +66,6 @@ protected override void OnWriteHelp()
Logger?.LogInformation("{help}", " script create <Schema> <Table> Creates a SQL script to perform a CREATE TABLE.");
Logger?.LogInformation("{help}", " script refdata <Schema> <Table> Creates a SQL script to perform a CREATE TABLE as reference data.");
Logger?.LogInformation("{help}", " script schema <Schema> Creates a SQL script to perform a CREATE SCHEMA.");
Logger?.LogInformation("{help}", string.Empty);
}
}
}
2 changes: 1 addition & 1 deletion src/DbEx.SqlServer/SqlServerSchemaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public override string ToFormattedSqlType(DbColumnSchema schema, bool includeNul
public override string ToFormattedSqlStatementValue(DataParserArgs dataParserArgs, object? value) => value switch
{
null => "NULL",
string str => $"'{str.Replace("'", "''", StringComparison.Ordinal)}'",
string str => $"N'{str.Replace("'", "''", StringComparison.Ordinal)}'",
bool b => b ? "1" : "0",
Guid => $"'{value}'",
DateTime dt => $"'{dt.ToString(dataParserArgs.DateTimeFormat, System.Globalization.CultureInfo.InvariantCulture)}'",
Expand Down

0 comments on commit 3f242e0

Please sign in to comment.