1 Star 1 Fork 1

c./goframe框架

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pgsql_do_insert.go 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
admin 提交于 2024-11-05 01:30 +08:00 . 2024-11-5 替换中文提示完成.
// 版权归GoFrame作者(https://goframe.org)所有。保留所有权利。
//
// 本源代码形式受MIT许可证条款约束。
// 如果未随本文件一同分发MIT许可证副本,
// 您可以在https://github.com/gogf/gf处获取。
// md5:a9832f33b234e3f3
package pgsql
import (
"context"
"database/sql"
gdb "gitee.com/go_888/goframe/database/gdb"
gcode "gitee.com/go_888/goframe/errors/gcode"
gerror "gitee.com/go_888/goframe/errors/gerror"
)
// X底层插入 为给定的表插入或更新数据。 md5:2a62d01f344269b8
func (d *Driver) X底层插入(ctx context.Context, link gdb.Link, table string, list gdb.X类型_Map数组, option gdb.X结构_DoInsertOption) (result sql.Result, err error) {
switch option.InsertOption {
case gdb.X常量_InsertOptionReplace:
return nil, gerror.X创建错误码(
gcode.X变量_CodeNotSupported,
`pgsql 驱动不支持 Replace 操作`,
)
case gdb.X常量_InsertOptionIgnore:
return nil, gerror.X创建错误码(
gcode.X变量_CodeNotSupported,
`pgsql 驱动不支持 Insert Ignore 操作`,
)
case gdb.X常量_InsertOptionDefault:
tableFields, err := d.X取Core对象().X取DB对象().X取表字段信息Map(ctx, table)
if err == nil {
for _, field := range tableFields {
if field.Key == "pri" {
pkField := *field
ctx = context.WithValue(ctx, internalPrimaryKeyInCtx, pkField)
break
}
}
}
}
return d.X结构_Core.X底层插入(ctx, link, table, list, option)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/go_888/goframe.git
git@gitee.com:go_888/goframe.git
go_888
goframe
goframe框架
782a3f7170cf

搜索帮助