This commit is contained in:
violetgo 2013-12-30 18:21:07 -08:00
commit 9918c56e68
2 changed files with 7 additions and 0 deletions

View File

@ -67,6 +67,7 @@ type Engine struct {
Logger io.Writer
Cacher Cacher
UseCache bool
charset string
}
func (engine *Engine) SetMapper(mapper IMapper) {

View File

@ -6,6 +6,7 @@ import (
"os"
"reflect"
"runtime"
"strings"
"sync"
)
@ -28,6 +29,11 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
engine.dialect = &sqlite3{}
} else if driverName == MYSQL {
engine.dialect = &mysql{}
index := strings.Index(strings.ToLower(dataSourceName), "charset=")
tempstr := dataSourceName[index+8:]
index = strings.Index(strings.ToLower(tempstr), "&")
tempstr = tempstr[:index]
engine.charset = tempstr
} else if driverName == POSTGRES {
engine.dialect = &postgres{}
engine.Filters = append(engine.Filters, &PgSeqFilter{})