Skip to content

Commit

Permalink
Revert changes to other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Oct 29, 2021
1 parent 38b19da commit 94903a5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,21 @@ public virtual async Task FromSqlRaw_queryable_simple_columns_out_of_order_and_n

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task FromSqlRaw_queryable_composed(bool async)
public virtual async Task<string> FromSqlRaw_queryable_composed(bool async)
{
using var context = CreateContext();
var query = context.Set<Customer>().FromSqlRaw(NormalizeDelimitersInRawString("SELECT * FROM [Customers]"))
.Where(c => c.ContactName.Contains("z"));

var queryString = query.ToQueryString();

var actual = async
? await query.ToArrayAsync()
: query.ToArray();

Assert.Equal(14, actual.Length);

return queryString;
}

[ConditionalTheory]
Expand Down Expand Up @@ -708,7 +712,7 @@ public virtual async Task FromSqlRaw_queryable_with_null_parameter(bool async)

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task FromSqlRaw_queryable_with_parameters_and_closure(bool async)
public virtual async Task<string> FromSqlRaw_queryable_with_parameters_and_closure(bool async)
{
var city = "London";
var contactTitle = "Sales Representative";
Expand All @@ -717,6 +721,7 @@ public virtual async Task FromSqlRaw_queryable_with_parameters_and_closure(bool
var query = context.Set<Customer>().FromSqlRaw(
NormalizeDelimitersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city)
.Where(c => c.ContactTitle == contactTitle);
var queryString = query.ToQueryString();

var actual = async
? await query.ToArrayAsync()
Expand All @@ -725,6 +730,8 @@ public virtual async Task FromSqlRaw_queryable_with_parameters_and_closure(bool
Assert.Equal(3, actual.Length);
Assert.True(actual.All(c => c.City == "London"));
Assert.True(actual.All(c => c.ContactTitle == "Sales Representative"));

return queryString;
}

[ConditionalTheory]
Expand Down Expand Up @@ -1503,15 +1510,12 @@ public virtual async Task FromSqlRaw_composed_with_common_table_expression(bool
var query = context.Set<Customer>()
.FromSqlRaw(
NormalizeDelimitersInRawString(
@"
WITH [Customers2] AS (
@"WITH [Customers2] AS (
SELECT * FROM [Customers]
)
SELECT * FROM [Customers2]"))
.Where(c => c.ContactName.Contains("z"));

var queryString = query.ToQueryString();

var actual = async
? await query.ToArrayAsync()
: query.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Data.Common;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore.Diagnostics;
Expand Down Expand Up @@ -44,15 +45,21 @@ public override async Task FromSqlRaw_queryable_simple_columns_out_of_order_and_
@"SELECT ""Region"", ""PostalCode"", ""PostalCode"" AS ""Foo"", ""Phone"", ""Fax"", ""CustomerID"", ""Country"", ""ContactTitle"", ""ContactName"", ""CompanyName"", ""City"", ""Address"" FROM ""Customers""");
}

public override async Task FromSqlRaw_queryable_composed(bool async)
public override async Task<string> FromSqlRaw_queryable_composed(bool async)
{
await base.FromSqlRaw_queryable_composed(async);
var queryString = await base.FromSqlRaw_queryable_composed(async);

AssertSql(@"SELECT [m].[CustomerID], [m].[Address], [m].[City], [m].[CompanyName], [m].[ContactName], [m].[ContactTitle], [m].[Country], [m].[Fax], [m].[Phone], [m].[PostalCode], [m].[Region]
var expected =
@"SELECT [m].[CustomerID], [m].[Address], [m].[City], [m].[CompanyName], [m].[ContactName], [m].[ContactTitle], [m].[Country], [m].[Fax], [m].[Phone], [m].[PostalCode], [m].[Region]
FROM (
SELECT * FROM ""Customers""
) AS [m]
WHERE [m].[ContactName] LIKE N'%z%'");
WHERE [m].[ContactName] LIKE N'%z%'";

AssertSql(expected);
Assert.Equal(expected, queryString, ignoreLineEndingDifferences: true);

return null;
}

public override async Task FromSqlRaw_queryable_composed_after_removing_whitespaces(bool async)
Expand Down Expand Up @@ -328,9 +335,9 @@ public override async Task FromSqlRaw_queryable_with_null_parameter(bool async)
SELECT * FROM ""Employees"" WHERE ""ReportsTo"" = @p0 OR (""ReportsTo"" IS NULL AND @p0 IS NULL)");
}

public override async Task FromSqlRaw_queryable_with_parameters_and_closure(bool async)
public override async Task<string> FromSqlRaw_queryable_with_parameters_and_closure(bool async)
{
await base.FromSqlRaw_queryable_with_parameters_and_closure(async);
var queryString = await base.FromSqlRaw_queryable_with_parameters_and_closure(async);

AssertSql(
@"p0='London' (Size = 4000)
Expand All @@ -341,6 +348,8 @@ public override async Task FromSqlRaw_queryable_with_parameters_and_closure(bool
SELECT * FROM ""Customers"" WHERE ""City"" = @p0
) AS [m]
WHERE [m].[ContactTitle] = @__contactTitle_1");

return null;
}

public override async Task FromSqlRaw_queryable_simple_cache_key_includes_query_string(bool async)
Expand Down
27 changes: 16 additions & 11 deletions test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,37 @@ public FromSqlQuerySqliteTest(NorthwindQuerySqliteFixture<NoopModelCustomizer> f
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

public override async Task FromSqlRaw_queryable_composed(bool async)
public override async Task<string> FromSqlRaw_queryable_composed(bool async)
{
await base.FromSqlRaw_queryable_composed(async);
var queryString = await base.FromSqlRaw_queryable_composed(async);

AssertSql(
var expected =
@"SELECT ""m"".""CustomerID"", ""m"".""Address"", ""m"".""City"", ""m"".""CompanyName"", ""m"".""ContactName"", ""m"".""ContactTitle"", ""m"".""Country"", ""m"".""Fax"", ""m"".""Phone"", ""m"".""PostalCode"", ""m"".""Region""
FROM (
SELECT * FROM ""Customers""
) AS ""m""
WHERE ('z' = '') OR (instr(""m"".""ContactName"", 'z') > 0)");
WHERE ('z' = '') OR (instr(""m"".""ContactName"", 'z') > 0)";

Assert.Equal(expected, queryString, ignoreLineEndingDifferences: true);

return queryString;
}

public override async Task FromSqlRaw_queryable_with_parameters_and_closure(bool async)
public override async Task<string> FromSqlRaw_queryable_with_parameters_and_closure(bool async)
{
await base.FromSqlRaw_queryable_with_parameters_and_closure(async);
var queryString = await base.FromSqlRaw_queryable_with_parameters_and_closure(async);

AssertSql(
@"p0='London' (Size = 6)
@__contactTitle_1='Sales Representative' (Size = 20)
Assert.Equal(
@".param set p0 'London'
.param set @__contactTitle_1 'Sales Representative'
SELECT ""m"".""CustomerID"", ""m"".""Address"", ""m"".""City"", ""m"".""CompanyName"", ""m"".""ContactName"", ""m"".""ContactTitle"", ""m"".""Country"", ""m"".""Fax"", ""m"".""Phone"", ""m"".""PostalCode"", ""m"".""Region""
FROM (
SELECT * FROM ""Customers"" WHERE ""City"" = @p0
) AS ""m""
WHERE ""m"".""ContactTitle"" = @__contactTitle_1");
WHERE ""m"".""ContactTitle"" = @__contactTitle_1", queryString, ignoreLineEndingDifferences: true);

return queryString;
}

public override Task Bad_data_error_handling_invalid_cast_key(bool async)
Expand Down Expand Up @@ -76,7 +82,6 @@ public override async Task FromSqlRaw_composed_with_common_table_expression(bool
AssertSql(
@"SELECT ""m"".""CustomerID"", ""m"".""Address"", ""m"".""City"", ""m"".""CompanyName"", ""m"".""ContactName"", ""m"".""ContactTitle"", ""m"".""Country"", ""m"".""Fax"", ""m"".""Phone"", ""m"".""PostalCode"", ""m"".""Region""
FROM (
WITH ""Customers2"" AS (
SELECT * FROM ""Customers""
)
Expand Down

0 comments on commit 94903a5

Please sign in to comment.