1 Star 0 Fork 7

bits-chen/go-sqlbuilder

forked from 艾润物联/go-sqlbuilder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
drop_index.go 971 Bytes
一键复制 编辑 原始数据 按行查看 历史
Yoojia Chen 提交于 2018-05-24 22:49 . Refactoring package
package gsb
import (
"bytes"
)
//
// Author: 陈永佳 chenyongjia@parkingwang.com, yoojiachen@gmail.com
//
type DropIndexBuilder struct {
name string
table string
}
func DropIndex(indexName string) *DropIndexBuilder {
return &DropIndexBuilder{
name: indexName,
}
}
func (slf *DropIndexBuilder) OnTable(table string) *DropIndexBuilder {
slf.table = table
return slf
}
func (slf *DropIndexBuilder) compile() *bytes.Buffer {
if "" == slf.table {
panic("table not found, you should call 'OnTable(table)' method to set it")
}
//ALTER TABLE table_name DROP INDEX index_name
buf := new(bytes.Buffer)
buf.WriteString("ALTER TABLE ")
buf.WriteString(EscapeName(slf.table))
buf.WriteString(" DROP INDEX ")
buf.WriteString(EscapeName(slf.name))
return buf
}
func (slf *DropIndexBuilder) GetSQL() string {
return endOfSQL(slf.compile())
}
func (slf *DropIndexBuilder) Execute(prepare SQLPrepare) *Executor {
return newExecute(slf.GetSQL(), prepare)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bitschen/go-sqlbuilder.git
git@gitee.com:bitschen/go-sqlbuilder.git
bitschen
go-sqlbuilder
go-sqlbuilder
master

搜索帮助