This commit is contained in:
John Guo
2025-12-08 19:28:18 +08:00
parent 57e5126b44
commit 3658a09b52
2 changed files with 16 additions and 5 deletions

View File

@ -76,8 +76,13 @@ func (d *Driver) doMergeInsert(
}
foundPrimaryKey := false
for _, primaryKey := range primaryKeys {
if _, ok := list[0][primaryKey]; ok {
foundPrimaryKey = true
for dataKey := range list[0] {
if strings.EqualFold(dataKey, primaryKey) {
foundPrimaryKey = true
break
}
}
if foundPrimaryKey {
break
}
}

View File

@ -9,6 +9,7 @@ package pgsql
import (
"context"
"database/sql"
"strings"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gcode"
@ -37,9 +38,14 @@ func (d *Driver) DoInsert(
)
}
foundPrimaryKey := false
for _, conflictKey := range primaryKeys {
if _, ok := list[0][conflictKey]; ok {
foundPrimaryKey = true
for _, primaryKey := range primaryKeys {
for dataKey := range list[0] {
if strings.EqualFold(dataKey, primaryKey) {
foundPrimaryKey = true
break
}
}
if foundPrimaryKey {
break
}
}