Skip to content

Commit

Permalink
Merge pull request #3 from max-ieremenko/release/2.1.2
Browse files Browse the repository at this point in the history
Release/2.1.2
  • Loading branch information
max-ieremenko authored Nov 24, 2020
2 parents 5932f74 + 697fcd9 commit 228e43c
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 28 deletions.
3 changes: 2 additions & 1 deletion Build/build-scripts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ function Test-Unit($targetFramework) {
$sourceDir = Join-Path $sourceDir $targetFramework

$testList = Get-ChildItem -Path $sourceDir -Recurse -Filter *.Test.dll `
| ForEach-Object {$_.FullName}
| Where-Object FullName -NotMatch \\ref\\ `
| ForEach-Object {$_.FullName}

if (-not $testList.Count) {
throw ($Framework + " test list is empty.")
Expand Down
30 changes: 27 additions & 3 deletions Build/build-tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Task UnitTest -Depends InitializeTests `
, UnitTest452 `
, UnitTest472 `
, UnitTestcore22 `
, UnitTestcore31
, UnitTestcore31 `
, UnitTest50
Task Test -Depends InitializeTests `
, TestPublishModule `
, TestPowerShellDesktop `
Expand All @@ -22,10 +23,13 @@ Task Test -Depends InitializeTests `
, TestPowerShellCore702 `
, TestPowerShellCore703 `
, TestPowerShellCore710 `
, TestPowerShellCore720 `
, TestGlobalTool22 `
, TestGlobalTool31 `
, TestGlobalTool50 `
, TestNetCore22 `
, TestNetCore31
, TestNetCore31 `
, TestNet50

Task Initialize {
$script:nugetexe = Join-Path $PSScriptRoot "nuget.exe"
Expand Down Expand Up @@ -147,6 +151,10 @@ Task PackManualDownload {
$destination = Join-Path $out "SqlDatabase.$packageVersion-netcore31.zip"
$source = Join-Path $binDir "SqlDatabase\netcoreapp3.1\publish\*"
Compress-Archive -Path $source, $lic -DestinationPath $destination

$destination = Join-Path $out "SqlDatabase.$packageVersion-net50.zip"
$source = Join-Path $binDir "SqlDatabase\net5.0\publish\*"
Compress-Archive -Path $source, $lic -DestinationPath $destination
}

Task InitializeTests {
Expand Down Expand Up @@ -179,6 +187,10 @@ Task UnitTestcore31 {
Test-Unit "netcoreapp3.1"
}

Task UnitTest50 {
Test-Unit "net5.0"
}

Task TestPowerShellCore611 {
Test-PowerShellCore "mcr.microsoft.com/powershell:6.1.1-alpine-3.8"
}
Expand Down Expand Up @@ -224,7 +236,11 @@ Task TestPowerShellCore703 {
}

Task TestPowerShellCore710 {
Test-PowerShellCore "mcr.microsoft.com/powershell:7.1.0-rc.1-ubuntu-18.04-20200928"
Test-PowerShellCore "mcr.microsoft.com/powershell:7.1.0-ubuntu-18.04"
}

Task TestPowerShellCore720 {
Test-PowerShellCore "mcr.microsoft.com/powershell:7.2.0-preview.1-ubuntu-20.04"
}

Task TestPublishModule {
Expand Down Expand Up @@ -253,10 +269,18 @@ Task TestGlobalTool31 {
Test-GlobalTool "mcr.microsoft.com/dotnet/core/sdk:3.1"
}

Task TestGlobalTool50 {
Test-GlobalTool "mcr.microsoft.com/dotnet/sdk:5.0"
}

Task TestNetCore22 {
Test-NetCore "netcoreapp2.2" "microsoft/dotnet:2.2-runtime"
}

Task TestNetCore31 {
Test-NetCore "netcoreapp3.1" "mcr.microsoft.com/dotnet/core/runtime:3.1"
}

Task TestNet50 {
Test-NetCore "net5.0" "mcr.microsoft.com/dotnet/runtime:5.0"
}
6 changes: 3 additions & 3 deletions Examples/CSharpMirationStep/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
==========================================

Any assembly script is
- .exe or .dll .NET assembly
- target framework is 4.5.2 or .net core 2.2
- .exe or .dll for target framework is 4.5.2+
- .dll for .net core 2.2/3.1 or .net5.0
- has exactly one class with script implementation

This project is an example of script implementation.
The build output is 2.1_2.2.dll with target framework 4.5.2.
Due to the current dependencies, 2.1_2.2.dll works well on .net core 2.2.
Due to the current dependencies, 2.1_2.2.dll works well on .net core 2.2/3.1 and .net 5.0.

## Script source
Method [SqlDatabaseScript.Execute](SqlDatabaseScript.cs) implements a logic of script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SolutionScripts" Version="1.2.0" />
<PackageReference Include="SqlDatabase" Version="2.1.1" />
<PackageReference Include="SqlDatabase" Version="2.1.2" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SqlDatabase
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/SqlDatabase.svg?style=flat-square)](https://www.powershellgallery.com/packages/SqlDatabase)
[![GitHub release](https://img.shields.io/github/release/max-ieremenko/SqlDatabase.svg?style=flat-square&label=manual%20download)](https://github.com/max-ieremenko/SqlDatabase/releases)

Command-line tool and PowerShell module for SQL Server to execute scripts, export data and database migrations.
Command-line tool and PowerShell module for SQL Server allows to execute scripts, database migrations and export data.

Table of Contents
-----------------
Expand All @@ -30,11 +30,11 @@ Table of Contents
Installation
------------

PowerShell module is compatible with PowerShell Desktop 5.1 and Powershell Core 6.1.0+.
PowerShell module is compatible with Powershell Core 6.1+ and PowerShell Desktop 5.1.

Dotnet tool requires .Net Core SDK 2.2/3.1.
Dotnet tool requires SDK .Net 5.0 or .Net Core 2.2/3.1.

Command-line tool is compatible with .Net Framework 4.5.2+ and .Net Core runtime 2.2/3.1.
Command-line tool is compatible with .Net runtime 5.0, .Net Core runtime 2.2/3.1 and .Net Framework 4.5.2+.

### PowerShell, from gallery

Expand Down
2 changes: 1 addition & 1 deletion Sources/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.261" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Sources/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyVersion("2.1.2.0")]
[assembly: AssemblyFileVersion("2.1.2.0")]
3 changes: 2 additions & 1 deletion Sources/SqlDatabase.Package/choco/sqldatabase.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<iconUrl>https://github.com/max-ieremenko/SqlDatabase/raw/master/icon-32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Command-line tool and PowerShell module for SQL Server.</summary>
<description>SqlDatabase is a tool for SQL Server, allows executing scripts, database migrations and data export.</description>
<description>SqlDatabase is a tool for SQL Server, allows to execute scripts, database migrations and export data.
Requires Powershell Core 6.1+ or PowerShell Desktop 5.1.</description>
<releaseNotes>https://github.com/max-ieremenko/SqlDatabase/releases</releaseNotes>
<copyright>(C) 2018-2020 Max Ieremenko.</copyright>
<tags>sqlserver sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data</tags>
Expand Down
2 changes: 1 addition & 1 deletion Sources/SqlDatabase.Package/nuget/package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<icon>icon-32.png</icon>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Command-line tool and PowerShell module for SQL Server.</summary>
<description>SqlDatabase is a tool for SQL Server, allows executing scripts, database migrations and data export.</description>
<description>SqlDatabase is a tool for SQL Server, allows to execute scripts, database migrations and export data.</description>
<releaseNotes>https://github.com/max-ieremenko/SqlDatabase/releases</releaseNotes>
<copyright>(C) 2018-2020 Max Ieremenko.</copyright>
<tags>sqlserver sqlcmd migration-tool c-sharp command-line-tool miration-step sql-script sql-database database-migrations export-data</tags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Moq" Version="4.15.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Binary file modified Sources/SqlDatabase.PowerShell/SqlDatabase.psd1
Binary file not shown.
4 changes: 4 additions & 0 deletions Sources/SqlDatabase.Test/Export/DataExporterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ private static IEnumerable<TestCaseData> GetExportCases()
yield return new TestCaseData("DATETIME2", date, date) { TestName = "DATETIME2" };
yield return new TestCaseData("SMALLDATETIME", date.AddSeconds(-30), date.AddSeconds(30)) { TestName = "SMALLDATETIME" };
yield return new TestCaseData("TIME", date.TimeOfDay, date.TimeOfDay) { TestName = "TIME" };

var dateTimeOffset = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2));
yield return new TestCaseData("DATETIMEOFFSET", dateTimeOffset, dateTimeOffset) { TestName = "DATETIMEOFFSET" };

////yield return new TestCaseData() { TestName = "" };
}
}
Expand Down
19 changes: 19 additions & 0 deletions Sources/SqlDatabase.Test/Export/SqlWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public void BeforeEachTest()
_sut = new SqlWriter(new StringWriter(_output));
}

[TearDown]
public void AfterEachTest()
{
Console.WriteLine(_output);
}

[Test]
public void Null()
{
Expand Down Expand Up @@ -100,5 +106,18 @@ public void ValueEmptyByteArray()

Query.ExecuteScalar(_output.ToString()).ShouldBe(value);
}

[Test]
public void ValueDateTimeOffset()
{
var value = new DateTimeOffset(2020, 11, 23, 00, 02, 50, 999, TimeSpan.FromHours(2));

_sut
.Text("SELECT CAST(")
.Value(value)
.Text(" AS DATETIMEOFFSET)");

Query.ExecuteScalar(_output.ToString()).ShouldBe(value);
}
}
}
9 changes: 5 additions & 4 deletions Sources/SqlDatabase.Test/SqlDatabase.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp2.2;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp2.2;netcoreapp3.1;net5.0</TargetFrameworks>
<RootNamespace>SqlDatabase</RootNamespace>
<NoWarn>NU1702</NoWarn>
<OutputPath>..\..\bin\Tests</OutputPath>
Expand Down Expand Up @@ -30,6 +30,7 @@
<!-- fix configuration for .net core tests
https://github.com/dotnet/corefx/issues/22101 -->
<Copy SourceFiles="app.config" DestinationFiles="$(OutDir)\testhost.dll.config" />
<Copy SourceFiles="app.config" DestinationFiles="$(OutDir)\ReSharperTestRunner64.dll.config" />
</Target>

<ItemGroup>
Expand All @@ -52,11 +53,11 @@

<ItemGroup>
<PackageReference Include="Dapper.StrongName" Version="1.50.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Moq" Version="4.15.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
Expand Down
17 changes: 15 additions & 2 deletions Sources/SqlDatabase/Export/SqlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ private bool TryWriteValue(object value)
return true;
}

if (value is TimeSpan time)
if (value is TimeSpan timeSpan)
{
ValueTimeSpan(time);
ValueTimeSpan(timeSpan);
return true;
}

if (value is DateTimeOffset dateTimeOffset)
{
ValueDateTimeOffset(dateTimeOffset);
return true;
}

Expand Down Expand Up @@ -259,5 +265,12 @@ private void ValueTimeSpan(TimeSpan value)
Output.Write(value.ToString("g", CultureInfo.InvariantCulture));
Output.Write(Q);
}

private void ValueDateTimeOffset(DateTimeOffset value)
{
Output.Write(Q);
Output.Write(value.ToString("yyyy-MM-ddTHH:mm:ss.fffK", CultureInfo.InvariantCulture));
Output.Write(Q);
}
}
}
4 changes: 2 additions & 2 deletions Sources/SqlDatabase/SqlDatabase.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Condition="'$(GlobalTool)' != true">
<TargetFrameworks>net452;netcoreapp2.2;netcoreapp3.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp2.2;netcoreapp3.1;net5.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(GlobalTool)' == true">
<TargetFrameworks>netcoreapp2.2;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 228e43c

Please sign in to comment.