-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes the previous commit, unskips tests.
Something to do with `MemberAccessBindingExpressionVisitor` happens under some specific circumstances that coincide with a compiled query. Added an `IsSafeToVisit` helper to `NpgsqlSqlTranslating...Visitor` for an additional guard when handling arrays that could be some type of replaced parameter.
- Loading branch information
1 parent
42e0384
commit 03086e4
Showing
6 changed files
with
54 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
42 changes: 1 addition & 41 deletions
42
test/EFCore.PG.FunctionalTests/Query/CompiledQueryNpgsqlTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,15 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Query; | ||
using Microsoft.EntityFrameworkCore.TestModels.Northwind; | ||
using Microsoft.EntityFrameworkCore.Query; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query | ||
{ | ||
public class CompiledQueryNpgsqlTest : CompiledQueryTestBase<NorthwindQueryNpgsqlFixture<NoopModelCustomizer>> | ||
{ | ||
// ReSharper disable once UnusedParameter.Local | ||
public CompiledQueryNpgsqlTest(NorthwindQueryNpgsqlFixture<NoopModelCustomizer> fixture, ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
fixture.TestSqlLoggerFactory.Clear(); | ||
} | ||
|
||
[ConditionalFact(Skip = "Throws: Can't write CLR type System.String[] with handler type TextHandler")] | ||
public override void Query_with_array_parameter() | ||
{ | ||
var query = EF.CompileQuery( | ||
(NorthwindContext context, string[] args) | ||
=> context.Customers.Where(c => c.CustomerID == args[0])); | ||
|
||
using (var context = CreateContext()) | ||
{ | ||
var args = new[] { "ALFKI" }; | ||
|
||
// BUG: this passes | ||
var _ = context.Customers.Where(c => c.CustomerID == args[0]).ToList(); | ||
|
||
// BUG: this throws | ||
// System.InvalidCastException : Can't write CLR type System.String[] with handler type TextHandler | ||
var result = query(context, args).First().CustomerID; | ||
|
||
Assert.Equal("ALFKI", result); | ||
} | ||
|
||
using (var context = CreateContext()) | ||
{ | ||
Assert.Equal("ANATR", query(context, new[] { "ANATR" }).First().CustomerID); | ||
} | ||
} | ||
|
||
[ConditionalFact(Skip = "Throws: Can't write CLR type System.String[] with handler type TextHandler")] | ||
public override async Task Query_with_array_parameter_async() | ||
{ | ||
await base.Query_with_array_parameter_async(); | ||
} | ||
} | ||
} |