Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Efcore.Pg
提交
6cd895e7
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,发现更多精彩内容 >>
提交
6cd895e7
编写于
9月 09, 2022
作者:
S
Shay Rojansky
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix post-seeding sequence bumping logic
Fixes #2501
上级
f1a87fa6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
31 deletion
+14
-31
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
+14
-31
未找到文件。
src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
浏览文件 @
6cd895e7
...
...
@@ -70,39 +70,22 @@ public class NpgsqlMigrationsSqlGenerator : MigrationsSqlGenerator
void
AddSequenceBumpingForSeeding
()
{
// For all tables where we had data seeding insertions, get any identity/serial columns for those tables.
// For all tables where we had data seeding insertions, find all columns mapped to properties with identity/serial value
// generation strategy. We'll bump the sequences for those columns.
var
seededGeneratedColumns
=
operations
.
OfType
<
InsertDataOperation
>()
.
Select
(
o
=>
new
{
o
.
Schema
,
o
.
Table
})
.
Distinct
()
.
Select
(
t
=>
new
{
t
.
Schema
,
t
.
Table
,
Columns
=
(
model
?.
GetRelationalModel
().
FindTable
(
t
.
Table
,
t
.
Schema
)
?.
EntityTypeMappings
.
Select
(
m
=>
m
.
EntityType
)
??
Enumerable
.
Empty
<
IEntityType
>())
.
SelectMany
(
e
=>
e
.
GetDeclaredProperties
()
.
Where
(
p
=>
p
.
GetValueGenerationStrategy
()
switch
{
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
=>
true
,
NpgsqlValueGenerationStrategy
.
IdentityAlwaysColumn
=>
true
,
NpgsqlValueGenerationStrategy
.
SerialColumn
=>
true
,
_
=>
false
})
.
Select
(
p
=>
p
.
GetColumnName
(
StoreObjectIdentifier
.
Table
(
t
.
Table
,
t
.
Schema
))))
})
.
SelectMany
(
t
=>
t
.
Columns
.
Select
(
p
=>
new
{
t
.
Schema
,
t
.
Table
,
Column
=
p
!,
}))
t
=>
model
?.
GetRelationalModel
().
FindTable
(
t
.
Table
,
t
.
Schema
)?.
Columns
.
Where
(
c
=>
c
.
PropertyMappings
.
Any
(
p
=>
p
.
Property
.
GetValueGenerationStrategy
()
is
NpgsqlValueGenerationStrategy
.
IdentityByDefaultColumn
or
NpgsqlValueGenerationStrategy
.
IdentityAlwaysColumn
or
NpgsqlValueGenerationStrategy
.
SerialColumn
))
??
Enumerable
.
Empty
<
IColumn
>())
.
Distinct
()
.
ToArray
();
if
(!
seededGeneratedColumns
.
Any
())
...
...
@@ -117,9 +100,9 @@ void AddSequenceBumpingForSeeding()
// Weirdly, pg_get_serial_sequence accepts a standard quoted "schema"."table" inside its first
// parameter string literal, but the second one is a column name that shouldn't be double-quoted...
var
table
=
Dependencies
.
SqlGenerationHelper
.
DelimitIdentifier
(
c
.
Table
,
c
.
Schema
);
var
column
=
Dependencies
.
SqlGenerationHelper
.
DelimitIdentifier
(
c
.
Column
!
);
var
unquotedColumn
=
c
.
Column
.
Replace
(
"'"
,
"''"
);
var
table
=
Dependencies
.
SqlGenerationHelper
.
DelimitIdentifier
(
c
.
Table
.
Name
,
c
.
Table
.
Schema
);
var
column
=
Dependencies
.
SqlGenerationHelper
.
DelimitIdentifier
(
c
.
Name
);
var
unquotedColumn
=
c
.
Name
.
Replace
(
"'"
,
"''"
);
// When generating idempotent scripts, migration DDL is enclosed in anonymous DO blocks,
// where PERFORM must be used instead of SELECT
...
...
jobily
@jobily
mentioned in commit
347ac0a7
·
9月 18, 2023
mentioned in commit
347ac0a7
mentioned in commit 347ac0a78a51773dc33e1476385808993ac6374b
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录