U4-8954 - fix WhereIn issue with non-value-types
This commit is contained in:
36
src/Umbraco.Tests/Persistence/PetaPocoExpresionsTests.cs
Normal file
36
src/Umbraco.Tests/Persistence/PetaPocoExpresionsTests.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Tests.Persistence
|
||||
{
|
||||
[TestFixture]
|
||||
public class PetaPocoExpresionsTests
|
||||
{
|
||||
[Test]
|
||||
public void WhereInValueFieldTest()
|
||||
{
|
||||
var syntax = SqlSyntaxContext.SqlSyntaxProvider = new SqlCeSyntaxProvider();
|
||||
var sql = new Sql()
|
||||
.Select("*")
|
||||
.From<NodeDto>(syntax)
|
||||
.WhereIn<NodeDto>(x => x.NodeId, new[] { 1, 2, 3 }, syntax);
|
||||
Assert.AreEqual("SELECT *\nFROM [umbracoNode]\nWHERE ([umbracoNode].[id] IN (@0,@1,@2))", sql.SQL);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhereInObjectFieldTest()
|
||||
{
|
||||
// this test used to fail because x => x.Text was evaluated as a lambda
|
||||
// and returned "[umbracoNode].[text] = @0"... had to fix WhereIn.
|
||||
|
||||
var syntax = SqlSyntaxContext.SqlSyntaxProvider = new SqlCeSyntaxProvider();
|
||||
var sql = new Sql()
|
||||
.Select("*")
|
||||
.From<NodeDto>(syntax)
|
||||
.WhereIn<NodeDto>(x => x.Text, new[] { "a", "b", "c" }, syntax);
|
||||
Assert.AreEqual("SELECT *\nFROM [umbracoNode]\nWHERE ([umbracoNode].[text] IN (@0,@1,@2))", sql.SQL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Migrations\MigrationIssuesTests.cs" />
|
||||
<Compile Include="Persistence\Migrations\MigrationStartupHandlerTests.cs" />
|
||||
<Compile Include="Persistence\PetaPocoExpresionsTests.cs" />
|
||||
<Compile Include="Persistence\Repositories\RedirectUrlRepositoryTests.cs" />
|
||||
<Compile Include="TestHelpers\Entities\MockedPropertyTypes.cs" />
|
||||
<Compile Include="TryConvertToTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user