mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 22:00:55 +00:00
new query builder based on driver
This commit is contained in:
parent
c667895ce5
commit
f9a9b5a905
14
orm/qb.go
14
orm/qb.go
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package orm
|
package orm
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
type QueryBuilder interface {
|
type QueryBuilder interface {
|
||||||
Select(fields ...string) QueryWriter
|
Select(fields ...string) QueryWriter
|
||||||
From(tables ...string) QueryWriter
|
From(tables ...string) QueryWriter
|
||||||
@ -29,7 +31,15 @@ type QueryBuilder interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewQueryBuilder() (qb QueryBuilder) {
|
func NewQueryBuilder(driver string) (qb QueryBuilder, err error) {
|
||||||
qb = new(MySQLQueryBuilder)
|
if driver == "mysql" {
|
||||||
|
qb = new(MySQLQueryBuilder)
|
||||||
|
} else if driver == "postgres" {
|
||||||
|
err = errors.New("postgres querybuilder is not supported yet!")
|
||||||
|
} else if driver == "sqlite" {
|
||||||
|
err = errors.New("sqlite querybuilder is not supported yet!")
|
||||||
|
} else {
|
||||||
|
err = errors.New("unknown driver for query builder!")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user