mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
fix(contrib/drivers/pgsql): fix insert error when data struct field has nil in PgSQL (#3679)
This commit is contained in:
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/text/gregex"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
@ -19,9 +20,11 @@ import (
|
||||
|
||||
// ConvertValueForField converts value to database acceptable value.
|
||||
func (d *Driver) ConvertValueForField(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) {
|
||||
var (
|
||||
fieldValueKind = reflect.TypeOf(fieldValue).Kind()
|
||||
)
|
||||
if g.IsNil(fieldValue) {
|
||||
return d.Core.ConvertValueForField(ctx, fieldType, fieldValue)
|
||||
}
|
||||
|
||||
var fieldValueKind = reflect.TypeOf(fieldValue).Kind()
|
||||
|
||||
if fieldValueKind == reflect.Slice {
|
||||
// For pgsql, json or jsonb require '[]'
|
||||
|
||||
Reference in New Issue
Block a user