6 Star 28 Fork 7

艾润物联/go-sqlbuilder

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
drop_index.go 971 Bytes
Copy Edit Raw Blame History
Yoojia Chen authored 2018-05-17 21:33 +08:00 . Rename package from sqlx to gsb
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)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/iRainIoT/go-sqlbuilder.git
git@gitee.com:iRainIoT/go-sqlbuilder.git
iRainIoT
go-sqlbuilder
go-sqlbuilder
37658dd0e549

Search