4 Star 52 Fork 3

yunyouzi/sorm

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mapping.shentong.go 2.73 KB
一键复制 编辑 原始数据 按行查看 历史
kunyu 提交于 2023-06-14 17:57 +08:00 . first commit
package dialect
import (
"fmt"
"strings"
)
func NewMappingShenTong() (mapping *SqlMapping) {
// https://blog.csdn.net/asd051377305/article/details/108766792
mapping = &SqlMapping{
dialectType: TypeShenTong,
OwnerNamePackChar: "",
TableNamePackChar: "\"",
ColumnNamePackChar: "\"",
SqlValuePackChar: "'",
SqlValueEscapeChar: "'",
}
appendShenTongSql(mapping)
mapping.PackPageSql = func(selectSql string, pageSize int, pageNo int) (pageSql string) {
pageSql = selectSql + fmt.Sprintf(" LIMIT %d OFFSET %d", pageSize, pageSize*(pageNo-1))
return
}
mapping.PackLimitOffsetSql = func(selectSql string, limit int, offset int) (pageSql string) {
pageSql = selectSql + fmt.Sprintf(" LIMIT %d OFFSET %d", limit, offset)
return
}
/*mapping.ReplaceSqlVariable = func(sqlInfo string, args []interface{}) (variableSql string) {
strList := strings.Split(sqlInfo, "?")
if len(strList) < 1 {
variableSql = sqlInfo
return
}
variableSql = strList[0]
for i := 1; i < len(strList); i++ {
variableSql += ":" + strconv.Itoa(i)
variableSql += strList[i]
}
return
}*/
mapping.ReplaceSqlVariable = func(sqlInfo string, args []interface{}) (variableSql string) {
argCount := len(args)
if argCount == 0 {
variableSql = sqlInfo
return
}
variableSql = sqlInfo
for i := 1; i <= argCount; i++ {
variableSql = strings.Replace(variableSql, "?", fmt.Sprintf(":%v", i), 1)
}
return
}
for _, one := range shenTongColumnTypeList {
mapping.AddColumnTypeInfo(one)
}
for _, one := range shenTongIndexTypeList {
mapping.AddIndexTypeInfo(one)
}
return
}
var (
shenTongIndexTypeList []*IndexTypeInfo
)
func appendShenTongIndexType(indexType *IndexTypeInfo) {
shenTongIndexTypeList = append(shenTongIndexTypeList, indexType)
}
func init() {
appendShenTongIndexType(&IndexTypeInfo{Name: "", Format: "INDEX",
NotSupportDataTypes: []string{"CLOB", "BLOB"},
})
appendShenTongIndexType(&IndexTypeInfo{Name: "INDEX", Format: "INDEX",
NotSupportDataTypes: []string{"CLOB", "BLOB"},
})
appendShenTongIndexType(&IndexTypeInfo{Name: "NORMAL", Format: "INDEX",
NotSupportDataTypes: []string{"CLOB", "BLOB"},
})
appendShenTongIndexType(&IndexTypeInfo{Name: "UNIQUE", Format: "UNIQUE",
NotSupportDataTypes: []string{"CLOB", "BLOB"},
IndexTypeFormat: func(index *IndexModel) (indexTypeFormat string, err error) {
indexTypeFormat = "UNIQUE INDEX"
return
},
})
appendShenTongIndexType(&IndexTypeInfo{Name: "FULLTEXT", Format: "FULLTEXT",
IndexTypeFormat: func(index *IndexModel) (indexTypeFormat string, err error) {
return
},
})
appendShenTongIndexType(&IndexTypeInfo{Name: "SPATIAL", Format: "SPATIAL",
IndexTypeFormat: func(index *IndexModel) (indexTypeFormat string, err error) {
return
},
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhendliu/sorm.git
git@gitee.com:zhendliu/sorm.git
zhendliu
sorm
sorm
3c9351379c60

搜索帮助