1 Star 1 Fork 0

bigbase / pg

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
drop_table.go 734 Bytes
Copy Edit Raw Blame History
Vladimir Mihailenco authored 2017-05-17 12:13 . Add DropTable
package orm
import "errors"
type DropTableOptions struct {
IfExists 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(nil)")
}
b = append(b, "DROP TABLE "...)
if q.opt != nil && q.opt.IfExists {
b = append(b, "IF EXISTS "...)
}
b = q.q.appendTableName(b)
return b, nil
}
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v6.2.2

Search