diff --git a/contrib/drivers/pgsql/pgsql_do_insert.go b/contrib/drivers/pgsql/pgsql_do_insert.go index 55e6f761c06..77af8180017 100644 --- a/contrib/drivers/pgsql/pgsql_do_insert.go +++ b/contrib/drivers/pgsql/pgsql_do_insert.go @@ -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" @@ -39,8 +40,13 @@ func (d *Driver) DoInsert( } foundPrimaryKey := false for _, conflictKey := range primaryKeys { - if _, ok := list[0][conflictKey]; ok { - foundPrimaryKey = true + for dataKey := range list[0] { + if strings.EqualFold(dataKey, conflictKey) { + foundPrimaryKey = true + break + } + } + if foundPrimaryKey { break } }