Skip to content

Commit d5825ab

Browse files
authored
drivers/pgsql:pgsql returning id should use quotation marks,when primary key is capital (#3638)
1 parent 753965b commit d5825ab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/drivers/pgsql/pgsql_do_exec.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package pgsql
99
import (
1010
"context"
1111
"database/sql"
12+
"fmt"
1213
"strings"
1314

1415
"github.com/gogf/gf/v2/database/gdb"
@@ -55,7 +56,7 @@ func (d *Driver) DoExec(ctx context.Context, link gdb.Link, sql string, args ...
5556
// check if it is an insert operation.
5657
if !isUseCoreDoExec && pkField.Name != "" && strings.Contains(sql, "INSERT INTO") {
5758
primaryKey = pkField.Name
58-
sql += " RETURNING " + primaryKey
59+
sql += fmt.Sprintf(` RETURNING "%s"`, primaryKey)
5960
} else {
6061
// use default DoExec
6162
return d.Core.DoExec(ctx, link, sql, args...)

0 commit comments

Comments
 (0)