mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
Merge branch 'master' of https://github.com/gogf/gf
This commit is contained in:
commit
bc29e86e58
@ -14,6 +14,7 @@ package gdb
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@ -204,3 +205,21 @@ func (d *DriverPgsql) DoInsert(ctx context.Context, link Link, table string, lis
|
||||
return d.Core.DoInsert(ctx, link, table, list, option)
|
||||
}
|
||||
}
|
||||
|
||||
// ConvertDataForRecord converting for any data that will be inserted into table/collection as a record.
|
||||
func (d *DriverPgsql) ConvertDataForRecord(ctx context.Context, value interface{}) map[string]interface{} {
|
||||
data := DataToMapDeep(value)
|
||||
var err error
|
||||
for k, v := range data {
|
||||
if valuer, ok := v.(driver.Valuer); ok {
|
||||
data[k], err = valuer.Value()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
data[k] = d.Core.ConvertDataForRecordValue(ctx, v)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user