7f7b585ffb
- 在应用程序中新增对达梦数据库(DM)的配置和连接支持 - 实现 SetDmDB 函数以配置达梦数据库连接 - 更新数据库操作逻辑,支持达梦特有的 SQL 语法和功能 - 在相关文件中添加达梦数据库的处理逻辑,包括表创建、数据插入和查询 - 更新 go.mod 和 go.sum 文件以引入达梦数据库驱动 - 增强文档,详细说明达梦数据库的配置和使用方法
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
/*
|
|
* Copyright (c) 2000-2018, 达梦数据库有限公司.
|
|
* All rights reserved.
|
|
*/
|
|
package dm
|
|
|
|
import "strings"
|
|
|
|
type DmResult struct {
|
|
filterable
|
|
dmStmt *DmStatement
|
|
affectedRows int64
|
|
insertId int64
|
|
}
|
|
|
|
func newDmResult(bs *DmStatement, execInfo *execRetInfo) *DmResult {
|
|
result := DmResult{}
|
|
result.resetFilterable(&bs.filterable)
|
|
result.dmStmt = bs
|
|
result.affectedRows = execInfo.updateCount
|
|
|
|
if execInfo.lastInsertId == 0 && execInfo.hasResultSet && strings.Index(execInfo.nativeSQL, "/*DMGORM-UPSERT*/") == 0 {
|
|
if len(execInfo.rsDatas) > 0 && len(execInfo.rsDatas[0]) > 0 {
|
|
result.insertId = Dm_build_1346.Dm_build_1576(execInfo.rsDatas[0][1])
|
|
} else {
|
|
result.insertId = 0
|
|
}
|
|
} else {
|
|
result.insertId = execInfo.lastInsertId
|
|
}
|
|
result.idGenerator = dmResultIDGenerator
|
|
|
|
return &result
|
|
}
|
|
|
|
func (r *DmResult) LastInsertId() (int64, error) {
|
|
|
|
if len(r.filterChain.filters) == 0 {
|
|
return r.lastInsertId()
|
|
}
|
|
return r.filterChain.reset().DmResultLastInsertId(r)
|
|
}
|
|
|
|
func (r *DmResult) RowsAffected() (int64, error) {
|
|
|
|
if len(r.filterChain.filters) == 0 {
|
|
return r.rowsAffected()
|
|
}
|
|
return r.filterChain.reset().DmResultRowsAffected(r)
|
|
}
|
|
|
|
func (result *DmResult) lastInsertId() (int64, error) {
|
|
return result.insertId, nil
|
|
}
|
|
|
|
func (result *DmResult) rowsAffected() (int64, error) {
|
|
return result.affectedRows, nil
|
|
}
|