-
Notifications
You must be signed in to change notification settings - Fork 255
Implement Precompiled Query Tests #3289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88b2228
Initial add of Precompiled query tests
ChrisJollyAU 62c3fde
Add reference to Npgsql in the test helpers so things like NpgsqlTsVe…
ChrisJollyAU 9b343ae
Remove unneeded test
ChrisJollyAU fb00b56
Wrong argument type for PgAnyExpression constructor
ChrisJollyAU 101a028
Update test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlPrecompiled…
ChrisJollyAU 8595042
Tidy up some unneeded and fix last test
ChrisJollyAU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
91 changes: 91 additions & 0 deletions
91
test/EFCore.PG.FunctionalTests/Query/AdHocPrecompiledQueryNpgsqlTest.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; | ||
| using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; | ||
|
|
||
| namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; | ||
|
|
||
| public class AdHocPrecompiledQueryNpgsqlTest(ITestOutputHelper testOutputHelper) | ||
| : AdHocPrecompiledQueryRelationalTestBase(testOutputHelper) | ||
| { | ||
| protected override bool AlwaysPrintGeneratedSources | ||
| => false; | ||
|
|
||
| public override async Task Index_no_evaluatability() | ||
| { | ||
| await base.Index_no_evaluatability(); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| SELECT j."Id", j."IntList", j."JsonThing" | ||
| FROM "JsonEntities" AS j | ||
| WHERE j."IntList"[j."Id" + 1] = 2 | ||
| """); | ||
| } | ||
|
|
||
| public override async Task Index_with_captured_variable() | ||
| { | ||
| await base.Index_with_captured_variable(); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| @__id_0='1' | ||
|
|
||
| SELECT j."Id", j."IntList", j."JsonThing" | ||
| FROM "JsonEntities" AS j | ||
| WHERE j."IntList"[@__id_0 + 1] = 2 | ||
| """); | ||
| } | ||
|
|
||
| public override async Task JsonScalar() | ||
| { | ||
| await base.JsonScalar(); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| SELECT j."Id", j."IntList", j."JsonThing" | ||
| FROM "JsonEntities" AS j | ||
| WHERE (j."JsonThing" ->> 'StringProperty') = 'foo' | ||
| """); | ||
| } | ||
|
|
||
| public override async Task Materialize_non_public() | ||
| { | ||
| await base.Materialize_non_public(); | ||
|
|
||
| AssertSql( | ||
| """ | ||
| @p0='10' (Nullable = true) | ||
| @p1='9' (Nullable = true) | ||
| @p2='8' (Nullable = true) | ||
|
|
||
| INSERT INTO "NonPublicEntities" ("PrivateAutoProperty", "PrivateProperty", "_privateField") | ||
| VALUES (@p0, @p1, @p2) | ||
| RETURNING "Id"; | ||
| """, | ||
| // | ||
| """ | ||
| SELECT n."Id", n."PrivateAutoProperty", n."PrivateProperty", n."_privateField" | ||
| FROM "NonPublicEntities" AS n | ||
| LIMIT 2 | ||
| """); | ||
| } | ||
|
|
||
| [ConditionalFact] | ||
| public virtual void Check_all_tests_overridden() | ||
| => TestHelpers.AssertAllMethodsOverridden(GetType()); | ||
|
|
||
| protected override ITestStoreFactory TestStoreFactory | ||
| => NpgsqlTestStoreFactory.Instance; | ||
|
|
||
| protected override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers | ||
| => NpgsqlPrecompiledQueryTestHelpers.Instance; | ||
|
|
||
| protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| { | ||
| builder = base.AddOptions(builder); | ||
|
|
||
| // TODO: Figure out if there's a nice way to continue using the retrying strategy | ||
| var sqlServerOptionsBuilder = new NpgsqlDbContextOptionsBuilder(builder); | ||
| sqlServerOptionsBuilder.ExecutionStrategy(d => new NonRetryingExecutionStrategy(d)); | ||
| return builder; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.