1 Star 1 Fork 0

bigbase / pg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
drop_table.go 821 Bytes
一键复制 编辑 原始数据 按行查看 历史
package orm
import "errors"
type DropTableOptions struct {
IfExists bool
Cascade bool
}
func DropTable(db DB, model interface{}, opt *DropTableOptions) (Result, error) {
return NewQuery(db, model).DropTable(opt)
}
type dropTableQuery struct {
q *Query
opt *DropTableOptions
}
func (q dropTableQuery) Copy() QueryAppender {
return q
}
func (q dropTableQuery) Query() *Query {
return q.q
}
func (q dropTableQuery) AppendQuery(b []byte) ([]byte, error) {
if q.q.stickyErr != nil {
return nil, q.q.stickyErr
}
if q.q.model == nil {
return nil, errors.New("pg: Model is nil")
}
b = append(b, "DROP TABLE "...)
if q.opt != nil && q.opt.IfExists {
b = append(b, "IF EXISTS "...)
}
b = q.q.appendTableName(b)
if q.opt != nil && q.opt.Cascade {
b = append(b, " CASCADE"...)
}
return b, nil
}
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v6.6.8

搜索帮助