forked from npgsql/efcore.pg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdHocPrecompiledQueryNpgsqlTest.cs
More file actions
119 lines (96 loc) · 3.27 KB
/
AdHocPrecompiledQueryNpgsqlTest.cs
File metadata and controls
119 lines (96 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
namespace Microsoft.EntityFrameworkCore.Query;
public class AdHocPrecompiledQueryNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper)
: AdHocPrecompiledQueryRelationalTestBase(fixture, 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='1'
SELECT j."Id", j."IntList", j."JsonThing"
FROM "JsonEntities" AS j
WHERE j."IntList"[@id + 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
""");
}
public override async Task Projecting_property_requiring_converter_with_closure_is_not_supported()
{
await base.Projecting_property_requiring_converter_with_closure_is_not_supported();
AssertSql();
}
public override async Task Projecting_expression_requiring_converter_without_closure_works()
{
await base.Projecting_expression_requiring_converter_without_closure_works();
AssertSql(
"""
SELECT b."AudiobookDate"
FROM "Books" AS b
""");
}
public override async Task Projecting_entity_with_property_requiring_converter_with_closure_works()
{
await base.Projecting_entity_with_property_requiring_converter_with_closure_works();
AssertSql(
"""
SELECT b."Id", b."AudiobookDate", b."Name", b."PublishDate"
FROM "Books" AS b
""");
}
[ConditionalFact]
public virtual void Check_all_tests_overridden()
=> TestHelpers.AssertAllMethodsOverridden(GetType());
protected override ITestStoreFactory NonSharedTestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
protected override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers
=> NpgsqlPrecompiledQueryTestHelpers.Instance;
protected override DbContextOptionsBuilder AddNonSharedOptions(DbContextOptionsBuilder builder)
{
builder = base.AddNonSharedOptions(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;
}
}