2013-11-14 13:35:17 +04:00
|
|
|
package dialect
|
|
|
|
|
2014-03-16 05:28:43 +04:00
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var timeType = reflect.TypeOf(time.Time{})
|
|
|
|
|
2013-11-14 13:35:17 +04:00
|
|
|
type Dialect interface {
|
2013-11-16 16:47:25 +04:00
|
|
|
BinVar(i int) string
|
2013-11-14 14:59:11 +04:00
|
|
|
SupportLastInsertId() bool
|
2014-03-16 05:28:43 +04:00
|
|
|
SqlTag(value reflect.Value, size int) string
|
|
|
|
PrimaryKeyTag(value reflect.Value, size int) string
|
2013-11-14 14:59:11 +04:00
|
|
|
ReturningStr(key string) string
|
2013-11-30 10:52:01 +04:00
|
|
|
Quote(key string) string
|
2013-11-14 13:35:17 +04:00
|
|
|
}
|
|
|
|
|
2013-11-15 15:43:45 +04:00
|
|
|
func New(driver string) Dialect {
|
2013-11-14 13:35:17 +04:00
|
|
|
var d Dialect
|
|
|
|
switch driver {
|
|
|
|
case "postgres":
|
2013-11-14 14:59:11 +04:00
|
|
|
d = &postgres{}
|
2013-11-14 13:35:17 +04:00
|
|
|
case "mysql":
|
2013-11-14 14:59:11 +04:00
|
|
|
d = &mysql{}
|
2013-11-14 13:35:17 +04:00
|
|
|
case "sqlite3":
|
2013-11-14 14:59:11 +04:00
|
|
|
d = &sqlite3{}
|
2013-11-14 13:35:17 +04:00
|
|
|
}
|
2013-11-14 14:59:11 +04:00
|
|
|
return d
|
2013-11-14 13:35:17 +04:00
|
|
|
}
|