Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
147fb679
E
Efcore.Pg
项目概览
jobily
/
Efcore.Pg
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Efcore.Pg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
147fb679
编写于
9月 13, 2022
作者:
S
Shay Rojansky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sync EF Core to 7.0.0-rc.2.22462.15
上级
07dcbb8d
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
931 addition
and
281 deletion
+931
-281
Directory.Packages.props
Directory.Packages.props
+3
-3
NuGet.config
NuGet.config
+0
-9
global.json
global.json
+1
-1
src/EFCore.PG/Query/Expressions/Internal/PostgresDeleteExpression.cs
...PG/Query/Expressions/Internal/PostgresDeleteExpression.cs
+12
-3
src/EFCore.PG/Query/Internal/NpgsqlDeleteConvertingExpressionVisitor.cs
...Query/Internal/NpgsqlDeleteConvertingExpressionVisitor.cs
+1
-1
src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
+16
-0
src/EFCore.PG/Update/Internal/NpgsqlModificationCommandBatch.cs
...Core.PG/Update/Internal/NpgsqlModificationCommandBatch.cs
+2
-6
test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs
...ts/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs
+77
-16
test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs
...onalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs
+87
-15
test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs
...lTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs
+27
-0
test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs
...tionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs
+288
-130
test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs
...BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs
+47
-17
test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs
...lTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs
+47
-17
test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs
...BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs
+57
-25
test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs
...lTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs
+43
-15
test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs
...EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs
+3
-2
test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs
....FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs
+166
-6
test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs
test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs
+23
-0
test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs
test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs
+9
-5
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlFixture.cs
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlFixture.cs
+0
-9
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlTest.cs
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlTest.cs
+22
-1
未找到文件。
Directory.Packages.props
浏览文件 @
147fb679
<Project>
<PropertyGroup>
<EFCoreVersion>7.0.0-rc.
1.22426.7
</EFCoreVersion>
<MicrosoftExtensionsVersion>7.0.0-rc.
1.22426.10
</MicrosoftExtensionsVersion>
<EFCoreVersion>7.0.0-rc.
2.22462.15
</EFCoreVersion>
<MicrosoftExtensionsVersion>7.0.0-rc.
2.22462.6
</MicrosoftExtensionsVersion>
<NpgsqlVersion>7.0.0-preview.7</NpgsqlVersion>
</PropertyGroup>
...
...
@@ -22,7 +22,7 @@
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageVersion Include="xunit" Version="2.4.2
-pre.9
" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.0.1" />
</ItemGroup>
...
...
NuGet.config
浏览文件 @
147fb679
...
...
@@ -21,15 +21,6 @@
<
packageSource
key
=
"dotnet7"
>
<
package
pattern
=
"*"
/>
</
packageSource
>
<
packageSource
key
=
"dotnet-eng"
>
<!--
EF
Core
depends
on
xunit
2
.
4
.
2
-
pre
.
9
which
is
only
in
dotnet
-
eng
.
But
some
xunit
packages
still
need
to
come
from
nuget
.
org
,
so
we
cherry
-
pick
. -->
<
package
pattern
=
"xunit"
/>
<
package
pattern
=
"xunit.assert"
/>
<
package
pattern
=
"xunit.core"
/>
<
package
pattern
=
"xunit.extensibility.core"
/>
<
package
pattern
=
"xunit.extensibility.execution"
/>
</
packageSource
>
</
packageSourceMapping
>
</
configuration
>
global.json
浏览文件 @
147fb679
{
"sdk"
:
{
"version"
:
"7.0.100-
preview.7.22377.5
"
,
"version"
:
"7.0.100-
rc.1.22425.9
"
,
"rollForward"
:
"latestMajor"
,
"allowPrerelease"
:
"true"
}
...
...
src/EFCore.PG/Query/Expressions/Internal/PostgresDeleteExpression.cs
浏览文件 @
147fb679
...
...
@@ -20,11 +20,20 @@ public sealed class PostgresDeleteExpression : Expression, IPrintableExpression
/// </summary>
public
SqlExpression
?
Predicate
{
get
;
}
/// <summary>
/// The list of tags applied to this <see cref="DeleteExpression" />.
/// </summary>
public
ISet
<
string
>
Tags
{
get
;
}
/// <summary>
/// Creates a new instance of the <see cref="PostgresDeleteExpression" /> class.
/// </summary>
public
PostgresDeleteExpression
(
TableExpression
table
,
IReadOnlyList
<
TableExpressionBase
>
fromItems
,
SqlExpression
?
predicate
)
=>
(
Table
,
FromItems
,
Predicate
)
=
(
table
,
fromItems
,
predicate
);
public
PostgresDeleteExpression
(
TableExpression
table
,
IReadOnlyList
<
TableExpressionBase
>
fromItems
,
SqlExpression
?
predicate
,
ISet
<
string
>
tags
)
=>
(
Table
,
FromItems
,
Predicate
,
Tags
)
=
(
table
,
fromItems
,
predicate
,
tags
);
/// <inheritdoc />
public
override
Type
Type
...
...
@@ -48,7 +57,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
public
PostgresDeleteExpression
Update
(
SqlExpression
?
predicate
)
=>
predicate
==
Predicate
?
this
:
new
PostgresDeleteExpression
(
Table
,
FromItems
,
predicate
);
:
new
PostgresDeleteExpression
(
Table
,
FromItems
,
predicate
,
Tags
);
/// <inheritdoc />
public
void
Print
(
ExpressionPrinter
expressionPrinter
)
...
...
src/EFCore.PG/Query/Internal/NpgsqlDeleteConvertingExpressionVisitor.cs
浏览文件 @
147fb679
...
...
@@ -93,6 +93,6 @@ protected virtual Expression VisitDelete(DeleteExpression deleteExpression)
ExpressionType
.
AndAlso
,
joinPredicates
,
selectExpression
.
Predicate
,
typeof
(
bool
),
joinPredicates
.
TypeMapping
)
};
return
new
PostgresDeleteExpression
(
deleteExpression
.
Table
,
fromItems
,
predicate
);
return
new
PostgresDeleteExpression
(
deleteExpression
.
Table
,
fromItems
,
predicate
,
deleteExpression
.
Tags
);
}
}
src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs
浏览文件 @
147fb679
...
...
@@ -61,6 +61,22 @@ protected override Expression VisitExtension(Expression extensionExpression)
_
=>
base
.
VisitExtension
(
extensionExpression
)
};
/// <inheritdoc />
protected
override
void
GenerateRootCommand
(
Expression
queryExpression
)
{
switch
(
queryExpression
)
{
case
PostgresDeleteExpression
postgresDeleteExpression
:
GenerateTagsHeaderComment
(
postgresDeleteExpression
.
Tags
);
VisitPostgresDelete
(
postgresDeleteExpression
);
break
;
default
:
base
.
GenerateRootCommand
(
queryExpression
);
break
;
}
}
/// <inheritdoc />
protected
override
void
GenerateLimitOffset
(
SelectExpression
selectExpression
)
{
...
...
src/EFCore.PG/Update/Internal/NpgsqlModificationCommandBatch.cs
浏览文件 @
147fb679
...
...
@@ -55,7 +55,7 @@ protected override void Consume(RelationalDataReader reader)
int
nextPropagating
;
for
(
nextPropagating
=
commandIndex
;
nextPropagating
<
ModificationCommands
.
Count
&&
!
ModificationCommands
[
nextPropagating
].
RequiresResultPropagation
;
!
ResultSetMappings
[
nextPropagating
].
HasFlag
(
ResultSetMapping
.
HasResultRow
)
;
nextPropagating
++)
{
}
...
...
@@ -87,8 +87,6 @@ protected override void Consume(RelationalDataReader reader)
ThrowAggregateUpdateConcurrencyException
(
reader
,
commandIndex
,
1
,
0
);
}
Check
.
DebugAssert
(
modificationCommand
.
RequiresResultPropagation
,
"RequiresResultPropagation is false"
);
modificationCommand
.
PropagateResults
(
reader
);
npgsqlReader
.
NextResult
();
...
...
@@ -129,7 +127,7 @@ protected override async Task ConsumeAsync(RelationalDataReader reader, Cancella
int
nextPropagating
;
for
(
nextPropagating
=
commandIndex
;
nextPropagating
<
ModificationCommands
.
Count
&&
!
ModificationCommands
[
nextPropagating
].
RequiresResultPropagation
;
!
ResultSetMappings
[
nextPropagating
].
HasFlag
(
ResultSetMapping
.
HasResultRow
)
;
nextPropagating
++)
{
}
...
...
@@ -163,8 +161,6 @@ await ThrowAggregateUpdateConcurrencyExceptionAsync(reader, commandIndex, 1, 0,
.
ConfigureAwait
(
false
);
}
Check
.
DebugAssert
(
modificationCommand
.
RequiresResultPropagation
,
"RequiresResultPropagation is false"
);
modificationCommand
.
PropagateResults
(
reader
);
await
npgsqlReader
.
NextResultAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -4,10 +4,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
FiltersInheritanceBulkUpdatesNpgsqlTest
:
FiltersInheritanceBulkUpdatesTestBase
<
FiltersInheritanceBulkUpdatesNpgsqlFixture
>
{
public
FiltersInheritanceBulkUpdatesNpgsqlTest
(
FiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
FiltersInheritanceBulkUpdatesNpgsqlTest
(
FiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -60,6 +63,40 @@ public override async Task Delete_where_using_hierarchy_derived(bool async)
""");
}
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
(
"""
DELETE
FROM
"Animals"
AS
a
WHERE
a
.
"CountryId"
=
1
AND
EXISTS
(
SELECT
1
FROM
"Animals"
AS
a0
WHERE
a0
.
"CountryId"
=
1
GROUP
BY
a0
.
"CountryId"
HAVING
count
(*)::
int
<
3
AND
(
SELECT
a1
.
"Id"
FROM
"Animals"
AS
a1
WHERE
a1
.
"CountryId"
=
1
AND
a0
.
"CountryId"
=
a1
.
"CountryId"
LIMIT
1
)
=
a
.
"Id"
)
""");
}
public
override
async
Task
Delete_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
{
await
base
.
Delete_where_keyless_entity_mapped_to_sql_query
(
async
);
...
...
@@ -71,7 +108,23 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
{
await
base
.
Delete_where_hierarchy_subquery
(
async
);
AssertSql
();
AssertSql
(
"""
@__p_1
=
'3'
@__p_0
=
'0'
DELETE
FROM
"Animals"
AS
a
WHERE
EXISTS
(
SELECT
1
FROM
(
SELECT
a0
.
"Id"
,
a0
.
"CountryId"
,
a0
.
"Discriminator"
,
a0
.
"Name"
,
a0
.
"Species"
,
a0
.
"EagleId"
,
a0
.
"IsFlightless"
,
a0
.
"Group"
,
a0
.
"FoundOn"
FROM
"Animals"
AS
a0
WHERE
a0
.
"CountryId"
=
1
AND
a0
.
"Name"
=
'
Great
spotted
kiwi
'
ORDER
BY
a0
.
"Name"
NULLS
FIRST
LIMIT
@__p_1
OFFSET
@__p_0
)
AS
t
WHERE
t
.
"Id"
=
a
.
"Id"
)
""");
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
...
...
@@ -79,9 +132,11 @@ public override async Task Update_where_hierarchy(bool async)
await
base
.
Update_where_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Animals"" AS a
SET ""Name"" = 'Animal'
WHERE a.""CountryId"" = 1 AND a.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Animals"
AS
a
SET
"Name"
=
'
Animal
'
WHERE
a
.
"CountryId"
=
1
AND
a
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_hierarchy_subquery
(
bool
async
)
...
...
@@ -96,9 +151,11 @@ public override async Task Update_where_hierarchy_derived(bool async)
await
base
.
Update_where_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Animals"" AS a
SET ""Name"" = 'Kiwi'
WHERE a.""Discriminator"" = 'Kiwi' AND a.""CountryId"" = 1 AND a.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Animals"
AS
a
SET
"Name"
=
'
Kiwi
'
WHERE
a
.
"Discriminator"
=
'
Kiwi
'
AND
a
.
"CountryId"
=
1
AND
a
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_using_hierarchy
(
bool
async
)
...
...
@@ -106,12 +163,14 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
WHERE a.""CountryId"" = 1 AND c.""Id"" = a.""CountryId"" AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -119,12 +178,14 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
WHERE a.""CountryId"" = 1 AND c.""Id"" = a.""CountryId"" AND a.""Discriminator"" = 'Kiwi' AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"Discriminator"
=
'
Kiwi
'
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -4,10 +4,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
InheritanceBulkUpdatesNpgsqlTest
:
InheritanceBulkUpdatesTestBase
<
InheritanceBulkUpdatesNpgsqlFixture
>
{
public
InheritanceBulkUpdatesNpgsqlTest
(
InheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
InheritanceBulkUpdatesNpgsqlTest
(
InheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -71,17 +74,80 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
{
await
base
.
Delete_where_hierarchy_subquery
(
async
);
AssertSql
(
"""
@__p_1
=
'3'
@__p_0
=
'0'
DELETE
FROM
"Animals"
AS
a
WHERE
EXISTS
(
SELECT
1
FROM
(
SELECT
a0
.
"Id"
,
a0
.
"CountryId"
,
a0
.
"Discriminator"
,
a0
.
"Name"
,
a0
.
"Species"
,
a0
.
"EagleId"
,
a0
.
"IsFlightless"
,
a0
.
"Group"
,
a0
.
"FoundOn"
FROM
"Animals"
AS
a0
WHERE
a0
.
"Name"
=
'
Great
spotted
kiwi
'
ORDER
BY
a0
.
"Name"
NULLS
FIRST
LIMIT
@__p_1
OFFSET
@__p_0
)
AS
t
WHERE
t
.
"Id"
=
a
.
"Id"
)
""");
}
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
(
"""
DELETE
FROM
"Animals"
AS
a
WHERE
EXISTS
(
SELECT
1
FROM
"Animals"
AS
a0
GROUP
BY
a0
.
"CountryId"
HAVING
count
(*)::
int
<
3
AND
(
SELECT
a1
.
"Id"
FROM
"Animals"
AS
a1
WHERE
a0
.
"CountryId"
=
a1
.
"CountryId"
LIMIT
1
)
=
a
.
"Id"
)
""");
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
(
"""
DELETE
FROM
"Animals"
AS
a
WHERE
EXISTS
(
SELECT
1
FROM
"Animals"
AS
a0
GROUP
BY
a0
.
"CountryId"
HAVING
count
(*)::
int
<
3
AND
(
SELECT
a1
.
"Id"
FROM
"Animals"
AS
a1
WHERE
a0
.
"CountryId"
=
a1
.
"CountryId"
LIMIT
1
)
=
a
.
"Id"
)
""");
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
{
await
base
.
Update_where_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Animals"" AS a
SET ""Name"" = 'Animal'
WHERE a.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Animals"
AS
a
SET
"Name"
=
'
Animal
'
WHERE
a
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_hierarchy_subquery
(
bool
async
)
...
...
@@ -96,9 +162,11 @@ public override async Task Update_where_hierarchy_derived(bool async)
await
base
.
Update_where_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Animals"" AS a
SET ""Name"" = 'Kiwi'
WHERE a.""Discriminator"" = 'Kiwi' AND a.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Animals"
AS
a
SET
"Name"
=
'
Kiwi
'
WHERE
a
.
"Discriminator"
=
'
Kiwi
'
AND
a
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_using_hierarchy
(
bool
async
)
...
...
@@ -106,12 +174,14 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
WHERE c.""Id"" = a.""CountryId"" AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
WHERE
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -119,12 +189,14 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
WHERE c.""Id"" = a.""CountryId"" AND a.""Discriminator"" = 'Kiwi' AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
WHERE
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"Discriminator"
=
'
Kiwi
'
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -14,6 +14,33 @@ public class NonSharedModelBulkUpdatesSqlServerTest : NonSharedModelBulkUpdatesT
public
virtual
void
Check_all_tests_overridden
()
=>
TestHelpers
.
AssertAllMethodsOverridden
(
GetType
());
public
override
async
Task
Delete_aggregate_root_when_eager_loaded_owned_collection
(
bool
async
)
{
await
base
.
Delete_aggregate_root_when_eager_loaded_owned_collection
(
async
);
AssertSql
(
"""
DELETE
FROM
"Owner"
AS
o
""");
}
public
override
async
Task
Delete_aggregate_root_when_table_sharing_with_owned
(
bool
async
)
{
await
base
.
Delete_aggregate_root_when_table_sharing_with_owned
(
async
);
AssertSql
(
"""
DELETE
FROM
"Owner"
AS
o
""");
}
public
override
async
Task
Delete_aggregate_root_when_table_sharing_with_non_owned_throws
(
bool
async
)
{
await
base
.
Delete_aggregate_root_when_table_sharing_with_non_owned_throws
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_predicate_based_on_optional_navigation
(
bool
async
)
{
await
base
.
Delete_predicate_based_on_optional_navigation
(
async
);
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
此差异已折叠。
点击以展开。
test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -5,10 +5,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
TPCFiltersInheritanceBulkUpdatesNpgsqlTest
:
TPCFiltersInheritanceBulkUpdatesTestBase
<
TPCFiltersInheritanceBulkUpdatesNpgsqlFixture
>
{
public
TPCFiltersInheritanceBulkUpdatesNpgsqlTest
(
TPCFiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
TPCFiltersInheritanceBulkUpdatesNpgsqlTest
(
TPCFiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -80,7 +83,28 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
{
await
base
.
Update_where_hierarchy
(
async
);
...
...
@@ -99,9 +123,11 @@ public override async Task Update_where_hierarchy_derived(bool async)
await
base
.
Update_where_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Kiwi"" AS k
SET ""Name"" = 'Kiwi'
WHERE k.""CountryId"" = 1 AND k.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Kiwi"
AS
k
SET
"Name"
=
'
Kiwi
'
WHERE
k
.
"CountryId"
=
1
AND
k
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_using_hierarchy
(
bool
async
)
...
...
@@ -109,18 +135,20 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM
(
SELECT e."
"Id"", e.""CountryId"", e.""Name"", e.""Species"", e.""EagleId"", e.""IsFlightless"", e.""Group"", NULL AS ""FoundOn"", 'Eagle' AS ""Discriminator"
"
FROM "
"Eagle"
" AS e
SELECT
e
.
"
Id"
,
e
.
"CountryId"
,
e
.
"Name"
,
e
.
"Species"
,
e
.
"EagleId"
,
e
.
"IsFlightless"
,
e
.
"Group"
,
NULL
AS
"FoundOn"
,
'
Eagle
'
AS
"Discriminator
"
FROM
"
Eagle
"
AS
e
UNION
ALL
SELECT k."
"Id"", k.""CountryId"", k.""Name"", k.""Species"", k.""EagleId"", k.""IsFlightless"", NULL AS ""Group"", k.""FoundOn"", 'Kiwi' AS ""Discriminator"
"
FROM "
"Kiwi"
" AS k
SELECT
k
.
"
Id"
,
k
.
"CountryId"
,
k
.
"Name"
,
k
.
"Species"
,
k
.
"EagleId"
,
k
.
"IsFlightless"
,
NULL
AS
"Group"
,
k
.
"FoundOn"
,
'
Kiwi
'
AS
"Discriminator
"
FROM
"
Kiwi
"
AS
k
)
AS
t
WHERE t.""CountryId"" = 1 AND c.""Id"" = t.""CountryId"" AND t.""CountryId"" > 0) > 0"
);
WHERE
t
.
"CountryId"
=
1
AND
c
.
"Id"
=
t
.
"CountryId"
AND
t
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -128,15 +156,17 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM
(
SELECT k."
"Id"", k.""CountryId"", k.""Name"", k.""Species"", k.""EagleId"", k.""IsFlightless"", NULL AS ""Group"", k.""FoundOn"", 'Kiwi' AS ""Discriminator"
"
FROM "
"Kiwi"
" AS k
SELECT
k
.
"
Id"
,
k
.
"CountryId"
,
k
.
"Name"
,
k
.
"Species"
,
k
.
"EagleId"
,
k
.
"IsFlightless"
,
NULL
AS
"Group"
,
k
.
"FoundOn"
,
'
Kiwi
'
AS
"Discriminator
"
FROM
"
Kiwi
"
AS
k
)
AS
t
WHERE t.""CountryId"" = 1 AND c.""Id"" = t.""CountryId"" AND t.""CountryId"" > 0) > 0"
);
WHERE
t
.
"CountryId"
=
1
AND
c
.
"Id"
=
t
.
"CountryId"
AND
t
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -5,10 +5,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
TPCInheritanceBulkUpdatesNpgsqlTest
:
TPCInheritanceBulkUpdatesTestBase
<
TPCInheritanceBulkUpdatesNpgsqlFixture
>
{
public
TPCInheritanceBulkUpdatesNpgsqlTest
(
TPCInheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
TPCInheritanceBulkUpdatesNpgsqlTest
(
TPCInheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -80,7 +83,28 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
{
await
base
.
Update_where_hierarchy
(
async
);
...
...
@@ -99,9 +123,11 @@ public override async Task Update_where_hierarchy_derived(bool async)
await
base
.
Update_where_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Kiwi"" AS k
SET ""Name"" = 'Kiwi'
WHERE k.""Name"" = 'Great spotted kiwi'"
);
"""
UPDATE
"Kiwi"
AS
k
SET
"Name"
=
'
Kiwi
'
WHERE
k
.
"Name"
=
'
Great
spotted
kiwi
'
""");
}
public
override
async
Task
Update_where_using_hierarchy
(
bool
async
)
...
...
@@ -109,18 +135,20 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM
(
SELECT e."
"Id"", e.""CountryId"", e.""Name"", e.""Species"", e.""EagleId"", e.""IsFlightless"", e.""Group"", NULL AS ""FoundOn"", 'Eagle' AS ""Discriminator"
"
FROM "
"Eagle"
" AS e
SELECT
e
.
"
Id"
,
e
.
"CountryId"
,
e
.
"Name"
,
e
.
"Species"
,
e
.
"EagleId"
,
e
.
"IsFlightless"
,
e
.
"Group"
,
NULL
AS
"FoundOn"
,
'
Eagle
'
AS
"Discriminator
"
FROM
"
Eagle
"
AS
e
UNION
ALL
SELECT k."
"Id"", k.""CountryId"", k.""Name"", k.""Species"", k.""EagleId"", k.""IsFlightless"", NULL AS ""Group"", k.""FoundOn"", 'Kiwi' AS ""Discriminator"
"
FROM "
"Kiwi"
" AS k
SELECT
k
.
"
Id"
,
k
.
"CountryId"
,
k
.
"Name"
,
k
.
"Species"
,
k
.
"EagleId"
,
k
.
"IsFlightless"
,
NULL
AS
"Group"
,
k
.
"FoundOn"
,
'
Kiwi
'
AS
"Discriminator
"
FROM
"
Kiwi
"
AS
k
)
AS
t
WHERE c.""Id"" = t.""CountryId"" AND t.""CountryId"" > 0) > 0"
);
WHERE
c
.
"Id"
=
t
.
"CountryId"
AND
t
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -128,15 +156,17 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM
(
SELECT k."
"Id"", k.""CountryId"", k.""Name"", k.""Species"", k.""EagleId"", k.""IsFlightless"", NULL AS ""Group"", k.""FoundOn"", 'Kiwi' AS ""Discriminator"
"
FROM "
"Kiwi"
" AS k
SELECT
k
.
"
Id"
,
k
.
"CountryId"
,
k
.
"Name"
,
k
.
"Species"
,
k
.
"EagleId"
,
k
.
"IsFlightless"
,
NULL
AS
"Group"
,
k
.
"FoundOn"
,
'
Kiwi
'
AS
"Discriminator
"
FROM
"
Kiwi
"
AS
k
)
AS
t
WHERE c.""Id"" = t.""CountryId"" AND t.""CountryId"" > 0) > 0"
);
WHERE
c
.
"Id"
=
t
.
"CountryId"
AND
t
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -5,10 +5,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
TPTFiltersInheritanceBulkUpdatesSqlServerTest
:
TPTFiltersInheritanceBulkUpdatesTestBase
<
TPTFiltersInheritanceBulkUpdatesNpgsqlFixture
>
{
public
TPTFiltersInheritanceBulkUpdatesSqlServerTest
(
TPTFiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
TPTFiltersInheritanceBulkUpdatesSqlServerTest
(
TPTFiltersInheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
// Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -31,12 +34,14 @@ public override async Task Delete_where_using_hierarchy(bool async)
AssertSql
(
"""
DELETE
FROM
[
c
]
FROM
[
Countries
]
AS
[
c
]
DELETE
FROM
"Countries"
AS
c
WHERE
(
SELECT
COUNT
(*)
FROM
[
Animals
]
AS
[
a
]
WHERE
[
a
].[
CountryId
]
=
1
AND
[
c
].[
Id
]
=
[
a
].[
CountryId
]
AND
[
a
].[
CountryId
]
>
0
)
>
0
SELECT
count
(*)::
int
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
...
...
@@ -46,12 +51,14 @@ public override async Task Delete_where_using_hierarchy_derived(bool async)
AssertSql
(
"""
DELETE
FROM
[
c
]
FROM
[
Countries
]
AS
[
c
]
DELETE
FROM
"Countries"
AS
c
WHERE
(
SELECT
COUNT
(*)
FROM
[
Animals
]
AS
[
a
]
WHERE
[
a
].[
CountryId
]
=
1
AND
[
c
].[
Id
]
=
[
a
].[
CountryId
]
AND
[
a
].[
Discriminator
]
=
N
'
Kiwi
'
AND
[
a
].[
CountryId
]
>
0
)
>
0
SELECT
count
(*)::
int
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
(
k
.
"Id"
IS
NOT
NULL
)
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
...
...
@@ -69,6 +76,27 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
{
await
base
.
Update_where_hierarchy
(
async
);
...
...
@@ -95,15 +123,17 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
LEFT JOIN ""Birds"" AS b ON a.""Id"" = b.""Id""
LEFT JOIN ""Eagle"" AS e ON a.""Id"" = e.""Id""
LEFT JOIN ""Kiwi"" AS k ON a.""Id"" = k.""Id""
WHERE a.""CountryId"" = 1 AND c.""Id"" = a.""CountryId"" AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -111,15 +141,17 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
LEFT JOIN ""Birds"" AS b ON a.""Id"" = b.""Id""
LEFT JOIN ""Eagle"" AS e ON a.""Id"" = e.""Id""
LEFT JOIN ""Kiwi"" AS k ON a.""Id"" = k.""Id""
WHERE a.""CountryId"" = 1 AND c.""Id"" = a.""CountryId"" AND (k.""Id"" IS NOT NULL) AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
a
.
"CountryId"
=
1
AND
c
.
"Id"
=
a
.
"CountryId"
AND
(
k
.
"Id"
IS
NOT
NULL
)
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -4,10 +4,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates;
public
class
TPTInheritanceBulkUpdatesNpgsqlTest
:
TPTInheritanceBulkUpdatesTestBase
<
TPTInheritanceBulkUpdatesNpgsqlFixture
>
{
public
TPTInheritanceBulkUpdatesNpgsqlTest
(
TPTInheritanceBulkUpdatesNpgsqlFixture
fixture
)
public
TPTInheritanceBulkUpdatesNpgsqlTest
(
TPTInheritanceBulkUpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
:
base
(
fixture
)
{
ClearLog
();
Fixture
.
TestSqlLoggerFactory
.
SetTestOutputHelper
(
testOutputHelper
);
}
public
override
async
Task
Delete_where_hierarchy
(
bool
async
)
...
...
@@ -52,6 +55,27 @@ public override async Task Delete_where_hierarchy_subquery(bool async)
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_3
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_3
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First
(
async
);
AssertSql
();
}
public
override
async
Task
Delete_GroupBy_Where_Select_First_2
(
bool
async
)
{
await
base
.
Delete_GroupBy_Where_Select_First_2
(
async
);
AssertSql
();
}
public
override
async
Task
Update_where_hierarchy
(
bool
async
)
{
await
base
.
Update_where_hierarchy
(
async
);
...
...
@@ -78,15 +102,17 @@ public override async Task Update_where_using_hierarchy(bool async)
await
base
.
Update_where_using_hierarchy
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
LEFT JOIN ""Birds"" AS b ON a.""Id"" = b.""Id""
LEFT JOIN ""Eagle"" AS e ON a.""Id"" = e.""Id""
LEFT JOIN ""Kiwi"" AS k ON a.""Id"" = k.""Id""
WHERE c.""Id"" = a.""CountryId"" AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
c
.
"Id"
=
a
.
"CountryId"
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_using_hierarchy_derived
(
bool
async
)
...
...
@@ -94,15 +120,17 @@ public override async Task Update_where_using_hierarchy_derived(bool async)
await
base
.
Update_where_using_hierarchy_derived
(
async
);
AssertExecuteUpdateSql
(
@"UPDATE ""Countries"" AS c
SET ""Name"" = 'Monovia'
"""
UPDATE
"Countries"
AS
c
SET
"Name"
=
'
Monovia
'
WHERE
(
SELECT
count
(*)::
int
FROM ""Animals"" AS a
LEFT JOIN ""Birds"" AS b ON a.""Id"" = b.""Id""
LEFT JOIN ""Eagle"" AS e ON a.""Id"" = e.""Id""
LEFT JOIN ""Kiwi"" AS k ON a.""Id"" = k.""Id""
WHERE c.""Id"" = a.""CountryId"" AND (k.""Id"" IS NOT NULL) AND a.""CountryId"" > 0) > 0"
);
FROM
"Animals"
AS
a
LEFT
JOIN
"Birds"
AS
b
ON
a
.
"Id"
=
b
.
"Id"
LEFT
JOIN
"Eagle"
AS
e
ON
a
.
"Id"
=
e
.
"Id"
LEFT
JOIN
"Kiwi"
AS
k
ON
a
.
"Id"
=
k
.
"Id"
WHERE
c
.
"Id"
=
a
.
"CountryId"
AND
(
k
.
"Id"
IS
NOT
NULL
)
AND
a
.
"CountryId"
>
0
)
>
0
""");
}
public
override
async
Task
Update_where_keyless_entity_mapped_to_sql_query
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -3,7 +3,8 @@
namespace
Npgsql.EntityFrameworkCore.PostgreSQL
;
public
class
ManyToManyTrackingNpgsqlTest
:
ManyToManyTrackingTestBase
<
ManyToManyTrackingNpgsqlTest
.
ManyToManyTrackingNpgsqlFixture
>
public
class
ManyToManyTrackingNpgsqlTest
:
ManyToManyTrackingRelationalTestBase
<
ManyToManyTrackingNpgsqlTest
.
ManyToManyTrackingNpgsqlFixture
>
{
public
ManyToManyTrackingNpgsqlTest
(
ManyToManyTrackingNpgsqlFixture
fixture
)
:
base
(
fixture
)
...
...
@@ -13,7 +14,7 @@ public ManyToManyTrackingNpgsqlTest(ManyToManyTrackingNpgsqlFixture fixture)
protected
override
void
UseTransaction
(
DatabaseFacade
facade
,
IDbContextTransaction
transaction
)
=>
facade
.
UseTransaction
(
transaction
.
GetDbTransaction
());
public
class
ManyToManyTrackingNpgsqlFixture
:
ManyToManyTracking
FixtureBas
e
public
class
ManyToManyTrackingNpgsqlFixture
:
ManyToManyTracking
RelationalFixtur
e
{
protected
override
ITestStoreFactory
TestStoreFactory
=>
NpgsqlTestStoreFactory
.
Instance
;
...
...
test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -2786,14 +2786,26 @@ public override async Task GroupBy_with_group_key_being_navigation(bool async)
await
base
.
GroupBy_with_group_key_being_navigation
(
async
);
AssertSql
(
);
"""
SELECT
o0
.
"OrderID"
,
o0
.
"CustomerID"
,
o0
.
"EmployeeID"
,
o0
.
"OrderDate"
,
COALESCE
(
sum
(
o
.
"OrderID"
),
0
)::
int
AS
"Aggregate"
FROM
"Order Details"
AS
o
INNER
JOIN
"Orders"
AS
o0
ON
o
.
"OrderID"
=
o0
.
"OrderID"
GROUP
BY
o0
.
"OrderID"
,
o0
.
"CustomerID"
,
o0
.
"EmployeeID"
,
o0
.
"OrderDate"
""");
}
public
override
async
Task
GroupBy_with_group_key_being_nested_navigation
(
bool
async
)
{
await
base
.
GroupBy_with_group_key_being_nested_navigation
(
async
);
AssertSql
();
AssertSql
(
"""
SELECT
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"City"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
,
COALESCE
(
sum
(
o
.
"OrderID"
),
0
)::
int
AS
"Aggregate"
FROM
"Order Details"
AS
o
INNER
JOIN
"Orders"
AS
o0
ON
o
.
"OrderID"
=
o0
.
"OrderID"
LEFT
JOIN
"Customers"
AS
c
ON
o0
.
"CustomerID"
=
c
.
"CustomerID"
GROUP
BY
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"City"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
""");
}
public
override
async
Task
GroupBy_with_group_key_being_navigation_with_entity_key_projection
(
bool
async
)
...
...
@@ -2801,7 +2813,12 @@ public override async Task GroupBy_with_group_key_being_navigation_with_entity_k
await
base
.
GroupBy_with_group_key_being_navigation_with_entity_key_projection
(
async
);
AssertSql
(
);
"""
SELECT
o0
.
"OrderID"
,
o0
.
"CustomerID"
,
o0
.
"EmployeeID"
,
o0
.
"OrderDate"
FROM
"Order Details"
AS
o
INNER
JOIN
"Orders"
AS
o0
ON
o
.
"OrderID"
=
o0
.
"OrderID"
GROUP
BY
o0
.
"OrderID"
,
o0
.
"CustomerID"
,
o0
.
"EmployeeID"
,
o0
.
"OrderDate"
""");
}
public
override
async
Task
GroupBy_with_group_key_being_navigation_with_complex_projection
(
bool
async
)
...
...
@@ -3519,11 +3536,154 @@ public override async Task GroupBy_aggregate_SelectMany(bool async)
AssertSql
();
}
public
override
async
Task
GroupBy_as_final_operator
(
bool
async
)
public
override
async
Task
Final_GroupBy_property_entity
(
bool
async
)
{
await
base
.
GroupBy_as_final_operator
(
async
);
await
base
.
Final_GroupBy_property_entity
(
async
);
AssertSql
();
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
FROM
"Customers"
AS
c
ORDER
BY
c
.
"City"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_anonymous_type
(
bool
async
)
{
await
base
.
Final_GroupBy_property_anonymous_type
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
FROM
"Customers"
AS
c
ORDER
BY
c
.
"City"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_multiple_properties_entity
(
bool
async
)
{
await
base
.
Final_GroupBy_multiple_properties_entity
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"Region"
,
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
FROM
"Customers"
AS
c
ORDER
BY
c
.
"City"
NULLS
FIRST
,
c
.
"Region"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_complex_key_entity
(
bool
async
)
{
await
base
.
Final_GroupBy_complex_key_entity
(
async
);
AssertSql
(
"""
SELECT
t
.
"City"
,
t
.
"Region"
,
t
.
"Constant"
,
t
.
"CustomerID"
,
t
.
"Address"
,
t
.
"CompanyName"
,
t
.
"ContactName"
,
t
.
"ContactTitle"
,
t
.
"Country"
,
t
.
"Fax"
,
t
.
"Phone"
,
t
.
"PostalCode"
FROM
(
SELECT
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"City"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
,
1
AS
"Constant"
FROM
"Customers"
AS
c
)
AS
t
ORDER
BY
t
.
"City"
NULLS
FIRST
,
t
.
"Region"
NULLS
FIRST
,
t
.
"Constant"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_nominal_type_entity
(
bool
async
)
{
await
base
.
Final_GroupBy_nominal_type_entity
(
async
);
AssertSql
(
"""
SELECT
t
.
"City"
,
t
.
"Constant"
,
t
.
"CustomerID"
,
t
.
"Address"
,
t
.
"CompanyName"
,
t
.
"ContactName"
,
t
.
"ContactTitle"
,
t
.
"Country"
,
t
.
"Fax"
,
t
.
"Phone"
,
t
.
"PostalCode"
,
t
.
"Region"
FROM
(
SELECT
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"City"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
,
1
AS
"Constant"
FROM
"Customers"
AS
c
)
AS
t
ORDER
BY
t
.
"City"
NULLS
FIRST
,
t
.
"Constant"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_anonymous_type_element_selector
(
bool
async
)
{
await
base
.
Final_GroupBy_property_anonymous_type_element_selector
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
FROM
"Customers"
AS
c
ORDER
BY
c
.
"City"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_entity_Include_collection
(
bool
async
)
{
await
base
.
Final_GroupBy_property_entity_Include_collection
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"CustomerID"
,
c
.
"Address"
,
c
.
"CompanyName"
,
c
.
"ContactName"
,
c
.
"ContactTitle"
,
c
.
"Country"
,
c
.
"Fax"
,
c
.
"Phone"
,
c
.
"PostalCode"
,
c
.
"Region"
,
o
.
"OrderID"
,
o
.
"CustomerID"
,
o
.
"EmployeeID"
,
o
.
"OrderDate"
FROM
"Customers"
AS
c
LEFT
JOIN
"Orders"
AS
o
ON
c
.
"CustomerID"
=
o
.
"CustomerID"
WHERE
c
.
"Country"
=
'
USA
'
ORDER
BY
c
.
"City"
NULLS
FIRST
,
c
.
"CustomerID"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_entity_projecting_collection
(
bool
async
)
{
await
base
.
Final_GroupBy_property_entity_projecting_collection
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"CustomerID"
,
o
.
"OrderID"
,
o
.
"CustomerID"
,
o
.
"EmployeeID"
,
o
.
"OrderDate"
FROM
"Customers"
AS
c
LEFT
JOIN
"Orders"
AS
o
ON
c
.
"CustomerID"
=
o
.
"CustomerID"
WHERE
c
.
"Country"
=
'
USA
'
ORDER
BY
c
.
"City"
NULLS
FIRST
,
c
.
"CustomerID"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_entity_projecting_collection_composed
(
bool
async
)
{
await
base
.
Final_GroupBy_property_entity_projecting_collection_composed
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"CustomerID"
,
t
.
"OrderID"
,
t
.
"CustomerID"
,
t
.
"EmployeeID"
,
t
.
"OrderDate"
FROM
"Customers"
AS
c
LEFT
JOIN
(
SELECT
o
.
"OrderID"
,
o
.
"CustomerID"
,
o
.
"EmployeeID"
,
o
.
"OrderDate"
FROM
"Orders"
AS
o
WHERE
o
.
"OrderID"
<
11000
)
AS
t
ON
c
.
"CustomerID"
=
t
.
"CustomerID"
WHERE
c
.
"Country"
=
'
USA
'
ORDER
BY
c
.
"City"
NULLS
FIRST
,
c
.
"CustomerID"
NULLS
FIRST
""");
}
public
override
async
Task
Final_GroupBy_property_entity_projecting_collection_and_single_result
(
bool
async
)
{
await
base
.
Final_GroupBy_property_entity_projecting_collection_and_single_result
(
async
);
AssertSql
(
"""
SELECT
c
.
"City"
,
c
.
"CustomerID"
,
t
.
"OrderID"
,
t
.
"CustomerID"
,
t
.
"EmployeeID"
,
t
.
"OrderDate"
,
t0
.
"OrderID"
,
t0
.
"CustomerID"
,
t0
.
"EmployeeID"
,
t0
.
"OrderDate"
FROM
"Customers"
AS
c
LEFT
JOIN
(
SELECT
o
.
"OrderID"
,
o
.
"CustomerID"
,
o
.
"EmployeeID"
,
o
.
"OrderDate"
FROM
"Orders"
AS
o
WHERE
o
.
"OrderID"
<
11000
)
AS
t
ON
c
.
"CustomerID"
=
t
.
"CustomerID"
LEFT
JOIN
(
SELECT
t1
.
"OrderID"
,
t1
.
"CustomerID"
,
t1
.
"EmployeeID"
,
t1
.
"OrderDate"
FROM
(
SELECT
o0
.
"OrderID"
,
o0
.
"CustomerID"
,
o0
.
"EmployeeID"
,
o0
.
"OrderDate"
,
ROW_NUMBER
()
OVER
(
PARTITION
BY
o0
.
"CustomerID"
ORDER
BY
o0
.
"OrderDate"
DESC
NULLS
LAST
)
AS
row
FROM
"Orders"
AS
o0
)
AS
t1
WHERE
t1
.
row
<=
1
)
AS
t0
ON
c
.
"CustomerID"
=
t0
.
"CustomerID"
WHERE
c
.
"Country"
=
'
USA
'
ORDER
BY
c
.
"City"
NULLS
FIRST
,
c
.
"CustomerID"
NULLS
FIRST
""");
}
public
override
async
Task
GroupBy_Where_with_grouping_result
(
bool
async
)
...
...
test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs
0 → 100644
浏览文件 @
147fb679
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using
Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL.Query
;
public
class
ToSqlQuerySqlServerTest
:
ToSqlQueryTestBase
{
protected
override
ITestStoreFactory
TestStoreFactory
=>
NpgsqlTestStoreFactory
.
Instance
;
[
ConditionalFact
]
public
virtual
void
Check_all_tests_overridden
()
=>
TestHelpers
.
AssertAllMethodsOverridden
(
GetType
());
// Base test implementation does not properly use identifier delimiters in raw SQL and isn't usable on PostgreSQL
public
override
Task
Entity_type_with_navigation_mapped_to_SqlQuery
(
bool
async
)
=>
Task
.
CompletedTask
;
private
void
AssertSql
(
params
string
[]
expected
)
=>
TestSqlLoggerFactory
.
AssertBaseline
(
expected
);
}
test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs
浏览文件 @
147fb679
...
...
@@ -18,13 +18,17 @@ public override async Task ExecuteUpdate_works_for_table_sharing(bool async)
await
base
.
ExecuteUpdate_works_for_table_sharing
(
async
);
AssertSql
(
@"UPDATE ""Vehicles"" AS v
SET ""SeatingCapacity"" = 1"
,
"""
UPDATE
"Vehicles"
AS
v
SET
"SeatingCapacity"
=
1
""",
//
@"SELECT NOT EXISTS (
"""
SELECT
NOT
EXISTS
(
SELECT
1
FROM ""Vehicles"" AS v
WHERE v.""SeatingCapacity"" <> 1)"
);
FROM
"Vehicles"
AS
v
WHERE
v
.
"SeatingCapacity"
<>
1
)
""");
}
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
)
...
...
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlFixture.cs
已删除
100644 → 0
浏览文件 @
07dcbb8d
using
Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL
;
public
class
UpdatesNpgsqlFixture
:
UpdatesRelationalFixture
{
protected
override
string
StoreName
{
get
;
}
=
"PartialUpdateNpgsqlTest"
;
protected
override
ITestStoreFactory
TestStoreFactory
=>
NpgsqlTestStoreFactory
.
Instance
;
}
\ No newline at end of file
test/EFCore.PG.FunctionalTests/UpdatesNpgsqlTest.cs
浏览文件 @
147fb679
using
Microsoft.EntityFrameworkCore.TestModels.UpdatesModel
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities
;
namespace
Npgsql.EntityFrameworkCore.PostgreSQL
;
public
class
UpdatesNpgsqlTest
:
UpdatesRelationalTestBase
<
UpdatesNpgsqlFixture
>
public
class
UpdatesNpgsqlTest
:
UpdatesRelationalTestBase
<
UpdatesNpgsql
Test
.
UpdatesNpgsql
Fixture
>
{
// ReSharper disable once UnusedParameter.Local
public
UpdatesNpgsqlTest
(
UpdatesNpgsqlFixture
fixture
,
ITestOutputHelper
testOutputHelper
)
...
...
@@ -50,4 +51,24 @@ public override void Identifiers_are_generated_correctly()
"IX_LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameT~1"
,
entityType2
.
GetIndexes
().
Single
().
GetDatabaseName
());
}
public
class
UpdatesNpgsqlFixture
:
UpdatesRelationalFixture
{
protected
override
ITestStoreFactory
TestStoreFactory
=>
NpgsqlTestStoreFactory
.
Instance
;
protected
override
void
OnModelCreating
(
ModelBuilder
modelBuilder
,
DbContext
context
)
{
base
.
OnModelCreating
(
modelBuilder
,
context
);
modelBuilder
.
HasPostgresExtension
(
"uuid-ossp"
);
modelBuilder
.
Entity
<
ProductBase
>()
.
Property
(
p
=>
p
.
Id
).
HasDefaultValueSql
(
"uuid_generate_v4()"
);
modelBuilder
.
Entity
<
Product
>().
HasIndex
(
p
=>
new
{
p
.
Name
,
p
.
Price
}).
IsUnique
().
HasFilter
(
@"""Name"" IS NOT NULL"
);
modelBuilder
.
Entity
<
Rodney
>().
Property
(
r
=>
r
.
Concurrency
).
HasColumnType
(
"timestamp without time zone"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录