Merge branch 'master' into enhancement-auto-transaction
This commit is contained in:
commit
9e0d5dcca0
|
@ -551,10 +551,13 @@ func (db *mysql) CreateTableSql(table *core.Table, tableName, storeEngine, chars
|
||||||
|
|
||||||
if len(charset) == 0 {
|
if len(charset) == 0 {
|
||||||
charset = db.URI().Charset
|
charset = db.URI().Charset
|
||||||
} else if len(charset) > 0 {
|
}
|
||||||
|
if len(charset) != 0 {
|
||||||
sql += " DEFAULT CHARSET " + charset
|
sql += " DEFAULT CHARSET " + charset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if db.rowFormat != "" {
|
if db.rowFormat != "" {
|
||||||
sql += " ROW_FORMAT=" + db.rowFormat
|
sql += " ROW_FORMAT=" + db.rowFormat
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ func (db *sqlite3) TableCheckSql(tableName string) (string, []interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *sqlite3) DropIndexSql(tableName string, index *core.Index) string {
|
func (db *sqlite3) DropIndexSql(tableName string, index *core.Index) string {
|
||||||
//var unique string
|
// var unique string
|
||||||
quote := db.Quote
|
quote := db.Quote
|
||||||
idxName := index.Name
|
idxName := index.Name
|
||||||
|
|
||||||
|
@ -452,5 +452,9 @@ type sqlite3Driver struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sqlite3Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
|
func (p *sqlite3Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
|
||||||
|
if strings.Contains(dataSourceName, "?") {
|
||||||
|
dataSourceName = dataSourceName[:strings.Index(dataSourceName, "?")]
|
||||||
|
}
|
||||||
|
|
||||||
return &core.Uri{DbType: core.SQLITE, DbName: dataSourceName}, nil
|
return &core.Uri{DbType: core.SQLITE, DbName: dataSourceName}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,11 @@ func (engine *Engine) AutoIncrStr() string {
|
||||||
return engine.dialect.AutoIncrStr()
|
return engine.dialect.AutoIncrStr()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
|
||||||
|
func (engine *Engine) SetConnMaxLifetime(d time.Duration) {
|
||||||
|
engine.db.SetConnMaxLifetime(d)
|
||||||
|
}
|
||||||
|
|
||||||
// SetMaxOpenConns is only available for go 1.2+
|
// SetMaxOpenConns is only available for go 1.2+
|
||||||
func (engine *Engine) SetMaxOpenConns(conns int) {
|
func (engine *Engine) SetMaxOpenConns(conns int) {
|
||||||
engine.db.SetMaxOpenConns(conns)
|
engine.db.SetMaxOpenConns(conns)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -99,6 +101,14 @@ func (eg *EngineGroup) SetColumnMapper(mapper core.IMapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
|
||||||
|
func (eg *EngineGroup) SetConnMaxLifetime(d time.Duration) {
|
||||||
|
eg.Engine.SetConnMaxLifetime(d)
|
||||||
|
for i := 0; i < len(eg.slaves); i++ {
|
||||||
|
eg.slaves[i].SetConnMaxLifetime(d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SetDefaultCacher set the default cacher
|
// SetDefaultCacher set the default cacher
|
||||||
func (eg *EngineGroup) SetDefaultCacher(cacher core.Cacher) {
|
func (eg *EngineGroup) SetDefaultCacher(cacher core.Cacher) {
|
||||||
eg.Engine.SetDefaultCacher(cacher)
|
eg.Engine.SetDefaultCacher(cacher)
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
// Copyright 2017 The Xorm Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build go1.6
|
|
||||||
|
|
||||||
package xorm
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
|
|
||||||
func (engine *Engine) SetConnMaxLifetime(d time.Duration) {
|
|
||||||
engine.db.SetConnMaxLifetime(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
|
|
||||||
func (eg *EngineGroup) SetConnMaxLifetime(d time.Duration) {
|
|
||||||
eg.Engine.SetConnMaxLifetime(d)
|
|
||||||
for i := 0; i < len(eg.slaves); i++ {
|
|
||||||
eg.slaves[i].SetConnMaxLifetime(d)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User describes a user
|
// User describes a user
|
||||||
|
|
|
@ -72,6 +72,7 @@ type EngineInterface interface {
|
||||||
|
|
||||||
Before(func(interface{})) *Session
|
Before(func(interface{})) *Session
|
||||||
Charset(charset string) *Session
|
Charset(charset string) *Session
|
||||||
|
ClearCache(...interface{}) error
|
||||||
CreateTables(...interface{}) error
|
CreateTables(...interface{}) error
|
||||||
DBMetas() ([]*core.Table, error)
|
DBMetas() ([]*core.Table, error)
|
||||||
Dialect() core.Dialect
|
Dialect() core.Dialect
|
||||||
|
@ -83,16 +84,22 @@ type EngineInterface interface {
|
||||||
GetTableMapper() core.IMapper
|
GetTableMapper() core.IMapper
|
||||||
GetTZDatabase() *time.Location
|
GetTZDatabase() *time.Location
|
||||||
GetTZLocation() *time.Location
|
GetTZLocation() *time.Location
|
||||||
|
MapCacher(interface{}, core.Cacher) error
|
||||||
NewSession() *Session
|
NewSession() *Session
|
||||||
NoAutoTime() *Session
|
NoAutoTime() *Session
|
||||||
Quote(string) string
|
Quote(string) string
|
||||||
SetCacher(string, core.Cacher)
|
SetCacher(string, core.Cacher)
|
||||||
|
SetConnMaxLifetime(time.Duration)
|
||||||
SetDefaultCacher(core.Cacher)
|
SetDefaultCacher(core.Cacher)
|
||||||
|
SetLogger(logger core.ILogger)
|
||||||
SetLogLevel(core.LogLevel)
|
SetLogLevel(core.LogLevel)
|
||||||
SetMapper(core.IMapper)
|
SetMapper(core.IMapper)
|
||||||
|
SetMaxOpenConns(int)
|
||||||
|
SetMaxIdleConns(int)
|
||||||
SetSchema(string)
|
SetSchema(string)
|
||||||
SetTZDatabase(tz *time.Location)
|
SetTZDatabase(tz *time.Location)
|
||||||
SetTZLocation(tz *time.Location)
|
SetTZLocation(tz *time.Location)
|
||||||
|
ShowExecTime(...bool)
|
||||||
ShowSQL(show ...bool)
|
ShowSQL(show ...bool)
|
||||||
Sync(...interface{}) error
|
Sync(...interface{}) error
|
||||||
Sync2(...interface{}) error
|
Sync2(...interface{}) error
|
||||||
|
|
|
@ -77,6 +77,9 @@ func (session *Session) nocacheGet(beanKind reflect.Kind, table *core.Table, bea
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
if !rows.Next() {
|
if !rows.Next() {
|
||||||
|
if rows.Err() != nil {
|
||||||
|
return false, rows.Err()
|
||||||
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
xorm.go
2
xorm.go
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build go1.8
|
||||||
|
|
||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
Loading…
Reference in New Issue