mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 19:57:40 +08:00
drivers/pgsql:pgsql returning id should use quotation marks,when primary key is capital (#3638)
This commit is contained in:
parent
753965b9a9
commit
d5825ab51c
@ -9,6 +9,7 @@ package pgsql
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
@ -55,7 +56,7 @@ func (d *Driver) DoExec(ctx context.Context, link gdb.Link, sql string, args ...
|
||||
// check if it is an insert operation.
|
||||
if !isUseCoreDoExec && pkField.Name != "" && strings.Contains(sql, "INSERT INTO") {
|
||||
primaryKey = pkField.Name
|
||||
sql += " RETURNING " + primaryKey
|
||||
sql += fmt.Sprintf(` RETURNING "%s"`, primaryKey)
|
||||
} else {
|
||||
// use default DoExec
|
||||
return d.Core.DoExec(ctx, link, sql, args...)
|
||||
|
Loading…
Reference in New Issue
Block a user