dotnetcore / dotnetcore/FreeSql
InsertOrUpdate方法唯一索引bug
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 910
- PR merge metrics
- No merged PRs in 30d
Description
#### 问题描述及重现代码:
InsertOrUpdate()
.SetSource(data)
.ExecuteAffrowsAsync();
在执行时,似乎是以主键为主,主键存在时执行更新,不存在时,执行插入。当表中除了主键外,还有唯一索引时,唯一索引存在时,则不会执行更新,而是直接报错,报索引冲突。
SetSource的重载方法,指定临时主键仅对 SqlServer/PostgreSQL/Firebird/达梦/南大通用/金仓/神通 有效
而InsertOrUpdate()
.SetSource(data).ExecuteMySqlBulkCopy()
则不存在此问题,唯一索引存在时,也会执行更新,不存在时,也会执行插入。
```c#
InsertOrUpdate()
.SetSource(data)
.ExecuteAffrowsAsync();
```
#### 数据库版本
mysql 5.7
#### 安装的Nuget包
各版本都有此问题
#### .net framework/. net core? 及具体版本
net core6-net core8
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.