Skip to content

Commit

Permalink
Merged changes from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ceastwood committed Mar 21, 2018
1 parent aa693ed commit 61f1ad1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
11 changes: 8 additions & 3 deletions QueryBuilder.Tests/QueryBuilder.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' or '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.1" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\QueryBuilder\QueryBuilder.csproj" />
<ProjectReference Include="..\SqlKata.Execution\SqlKata.Execution.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="NuGet.Build.Tasks.Pack" Version="4.6.1" />
<PackageReference Update="SourceLink.Create.CommandLine" Version="2.8.0" />
</ItemGroup>
</Project>
18 changes: 10 additions & 8 deletions QueryBuilder.Tests/QueryBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public void BasicSelect()
var q = new Query().From("users").Select("id", "name");
var c = Compile(q);

Assert.Equal(c[0], "SELECT [id], [name] FROM [users]");
Assert.Equal(c[1], "SELECT `id`, `name` FROM `users`");
Assert.Equal(c[2], "SELECT \"id\", \"name\" FROM \"users\"");
Assert.Equal("SELECT [id], [name] FROM [users]", c[0]);
Assert.Equal("SELECT `id`, `name` FROM `users`",c[1]);
Assert.Equal("SELECT \"id\", \"name\" FROM \"users\"",c[2]);
}

[Fact]
Expand Down Expand Up @@ -108,18 +108,20 @@ public void ColumnsEscaping()
Assert.Equal("SELECT [mycol[isthis]]] FROM [users]", c[0]);
}

[Fact]
public void DeepJoin()
{
var q = new Query().From("streets").DeepJoin("cities.countries");
var c = Compile(q);

Assert.Equal("SELECT * FROM [streets] INNER JOIN [cities] ON [streets].[cityId] = [cities].[Id] INNER JOIN [countries] ON [streets].[countryId] = [countries].[Id]", c[0]);
Assert.Equal("SELECT * FROM [streets] INNER JOIN [cities] ON [streets].[cityId] = [cities].[Id] INNER JOIN [countries] ON [cities].[countryId] = [countries].[Id]", c[0]);

Assert.Equal("SELECT * FROM `streets` INNER JOIN `cities` ON `streets`.`cityId` = `cities`.`Id` INNER JOIN `countries` ON `streets`.`countryId` = `countries`.`Id`", c[1]);
Assert.Equal("SELECT * FROM `streets` INNER JOIN `cities` ON `streets`.`cityId` = `cities`.`Id` INNER JOIN `countries` ON `cities`.`countryId` = `countries`.`Id`", c[1]);

Assert.Equal("SELECT * FROM \"streets\" INNER JOIN \"cities\" ON \"streets\".\"cityId\" = \"cities\".\"Id\" INNER JOIN \"countries\" ON \"streets\".\"countryId\" = \"countries\".\"Id\"", c[1]);
Assert.Equal("SELECT * FROM \"streets\" INNER JOIN \"cities\" ON \"streets\".\"cityId\" = \"cities\".\"Id\" INNER JOIN \"countries\" ON \"cities\".\"countryId\" = \"countries\".\"Id\"", c[2]);
}

[Fact]
public void CteAndBindings()
{
var query = new Query("Races")
Expand All @@ -143,8 +145,8 @@ public void CteAndBindings()

var c = Compile(query);

Assert.Equal("WITH [range] AS (SELECT [Number] FROM [Sequence] WHERE [Number] < 78) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS [row_num] FROM [Races]WHERE [Id] > 55 AND [Value] BETWEEN 18 AND 24) WHERE [[row_num]]] BETWEEN 21 AND 45", c[0]);
Assert.Equal("WITH `range` AS (SELECT `Id` FROM `seqtbl` WHERE `Id` < 33) SELECT * FROM `Races` WHERE `RaceAuthor` IN (SELECT `Name` FROM `Users` WHERE `Status` = Available) AND `Id` > 55 AND `Value` BETWEEN 18 AND 24", c[1]);
Assert.Equal("WITH [range] AS (SELECT [Number] FROM [Sequence] WHERE [Number] < 78) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS [row_num] FROM [Races] WHERE [Id] > 55 AND [Value] BETWEEN 18 AND 24) AS [subquery] WHERE [row_num] BETWEEN 21 AND 45", c[0]);
Assert.Equal("WITH `range` AS (SELECT `Id` FROM `seqtbl` WHERE `Id` < 33) SELECT * FROM `Races` WHERE `RaceAuthor` IN (SELECT `Name` FROM `Users` WHERE `Status` = 'Available') AND `Id` > 55 AND `Value` BETWEEN 18 AND 24", c[1]);

Assert.Equal("WITH \"range\" AS (SELECT \"d\" FROM generate_series(1, 33) as d) SELECT * FROM \"Races\" WHERE \"Name\" = 3778 AND \"Id\" > 55 AND \"Value\" BETWEEN 18 AND 24", c[2]);
}
Expand Down
9 changes: 7 additions & 2 deletions QueryBuilder/QueryBuilder.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!-- Implicit import of directory.build.props doesn't seem to work from the linux cli, import manually -->
<!-- <Import Condition="'$(OS)' != 'Windows_NT'" Project="..\Directory.build.props"/> -->
Expand All @@ -14,6 +14,11 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0"/>
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="NuGet.Build.Tasks.Pack" Version="4.6.1" />
<PackageReference Update="SourceLink.Create.CommandLine" Version="2.8.0" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions SqlKata.Execution/SqlKata.Execution.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<ItemGroup>
<PackageReference Include="dapper" Version="1.50.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="NuGet.Build.Tasks.Pack" Version="4.6.1" />
<PackageReference Update="SourceLink.Create.CommandLine" Version="2.8.0" />
</ItemGroup>
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net451</TargetFrameworks>
</PropertyGroup>
Expand Down

0 comments on commit 61f1ad1

Please sign in to comment.