fix bug
This commit is contained in:
commit
27d1248aa7
|
@ -0,0 +1,16 @@
|
|||
// +build go1.15
|
||||
|
||||
package xorm
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SetConnMaxIdleTime sets the maximum amount of time a connection may be idle.
|
||||
//
|
||||
// Expired connections may be closed lazily before reuse.
|
||||
//
|
||||
// If d <= 0, connections are not closed due to a connection's idle time.
|
||||
func (engine *Engine) SetConnMaxIdleTime(d time.Duration) {
|
||||
engine.DB().SetConnMaxIdleTime(d)
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// +build go1.15
|
||||
|
||||
package xorm
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// SetConnMaxIdleTime sets the maximum amount of time a connection may be idle.
|
||||
//
|
||||
// Expired connections may be closed lazily before reuse.
|
||||
//
|
||||
// If d <= 0, connections are not closed due to a connection's idle time.
|
||||
func (eg *EngineGroup) SetConnMaxIdleTime(d time.Duration) {
|
||||
eg.Engine.SetConnMaxIdleTime(d)
|
||||
for i := 0; i < len(eg.slaves); i++ {
|
||||
eg.slaves[i].SetConnMaxIdleTime(d)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
// +build !go1.15
|
||||
|
||||
package xorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm/caches"
|
||||
"xorm.io/xorm/contexts"
|
||||
"xorm.io/xorm/dialects"
|
||||
"xorm.io/xorm/log"
|
||||
"xorm.io/xorm/names"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
// EngineInterface defines the interface which Engine, EngineGroup will implementate.
|
||||
type EngineInterface interface {
|
||||
Interface
|
||||
|
||||
Before(func(interface{})) *Session
|
||||
Charset(charset string) *Session
|
||||
ClearCache(...interface{}) error
|
||||
Context(context.Context) *Session
|
||||
CreateTables(...interface{}) error
|
||||
DBMetas() ([]*schemas.Table, error)
|
||||
Dialect() dialects.Dialect
|
||||
DriverName() string
|
||||
DropTables(...interface{}) error
|
||||
DumpAllToFile(fp string, tp ...schemas.DBType) error
|
||||
GetCacher(string) caches.Cacher
|
||||
GetColumnMapper() names.Mapper
|
||||
GetDefaultCacher() caches.Cacher
|
||||
GetTableMapper() names.Mapper
|
||||
GetTZDatabase() *time.Location
|
||||
GetTZLocation() *time.Location
|
||||
ImportFile(fp string) ([]sql.Result, error)
|
||||
MapCacher(interface{}, caches.Cacher) error
|
||||
NewSession() *Session
|
||||
NoAutoTime() *Session
|
||||
Quote(string) string
|
||||
SetCacher(string, caches.Cacher)
|
||||
SetConnMaxLifetime(time.Duration)
|
||||
SetColumnMapper(names.Mapper)
|
||||
SetDefaultCacher(caches.Cacher)
|
||||
SetLogger(logger interface{})
|
||||
SetLogLevel(log.LogLevel)
|
||||
SetMapper(names.Mapper)
|
||||
SetMaxOpenConns(int)
|
||||
SetMaxIdleConns(int)
|
||||
SetQuotePolicy(dialects.QuotePolicy)
|
||||
SetSchema(string)
|
||||
SetTableMapper(names.Mapper)
|
||||
SetTZDatabase(tz *time.Location)
|
||||
SetTZLocation(tz *time.Location)
|
||||
AddHook(hook contexts.Hook)
|
||||
ShowSQL(show ...bool)
|
||||
Sync(...interface{}) error
|
||||
Sync2(...interface{}) error
|
||||
StoreEngine(storeEngine string) *Session
|
||||
TableInfo(bean interface{}) (*schemas.Table, error)
|
||||
TableName(interface{}, ...bool) string
|
||||
UnMapType(reflect.Type)
|
||||
EnableSessionID(bool)
|
||||
}
|
||||
|
||||
var (
|
||||
_ EngineInterface = &Engine{}
|
||||
_ EngineInterface = &EngineGroup{}
|
||||
)
|
|
@ -0,0 +1,73 @@
|
|||
// +build go1.15
|
||||
|
||||
package xorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm/caches"
|
||||
"xorm.io/xorm/contexts"
|
||||
"xorm.io/xorm/dialects"
|
||||
"xorm.io/xorm/log"
|
||||
"xorm.io/xorm/names"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
// EngineInterface defines the interface which Engine, EngineGroup will implementate.
|
||||
type EngineInterface interface {
|
||||
Interface
|
||||
|
||||
Before(func(interface{})) *Session
|
||||
Charset(charset string) *Session
|
||||
ClearCache(...interface{}) error
|
||||
Context(context.Context) *Session
|
||||
CreateTables(...interface{}) error
|
||||
DBMetas() ([]*schemas.Table, error)
|
||||
Dialect() dialects.Dialect
|
||||
DriverName() string
|
||||
DropTables(...interface{}) error
|
||||
DumpAllToFile(fp string, tp ...schemas.DBType) error
|
||||
GetCacher(string) caches.Cacher
|
||||
GetColumnMapper() names.Mapper
|
||||
GetDefaultCacher() caches.Cacher
|
||||
GetTableMapper() names.Mapper
|
||||
GetTZDatabase() *time.Location
|
||||
GetTZLocation() *time.Location
|
||||
ImportFile(fp string) ([]sql.Result, error)
|
||||
MapCacher(interface{}, caches.Cacher) error
|
||||
NewSession() *Session
|
||||
NoAutoTime() *Session
|
||||
Quote(string) string
|
||||
SetCacher(string, caches.Cacher)
|
||||
SetConnMaxLifetime(time.Duration)
|
||||
SetConnMaxIdleTime(time.Duration) // only go1.15 or higher
|
||||
SetColumnMapper(names.Mapper)
|
||||
SetDefaultCacher(caches.Cacher)
|
||||
SetLogger(logger interface{})
|
||||
SetLogLevel(log.LogLevel)
|
||||
SetMapper(names.Mapper)
|
||||
SetMaxOpenConns(int)
|
||||
SetMaxIdleConns(int)
|
||||
SetQuotePolicy(dialects.QuotePolicy)
|
||||
SetSchema(string)
|
||||
SetTableMapper(names.Mapper)
|
||||
SetTZDatabase(tz *time.Location)
|
||||
SetTZLocation(tz *time.Location)
|
||||
AddHook(hook contexts.Hook)
|
||||
ShowSQL(show ...bool)
|
||||
Sync(...interface{}) error
|
||||
Sync2(...interface{}) error
|
||||
StoreEngine(storeEngine string) *Session
|
||||
TableInfo(bean interface{}) (*schemas.Table, error)
|
||||
TableName(interface{}, ...bool) string
|
||||
UnMapType(reflect.Type)
|
||||
EnableSessionID(bool)
|
||||
}
|
||||
|
||||
var (
|
||||
_ EngineInterface = &Engine{}
|
||||
_ EngineInterface = &EngineGroup{}
|
||||
)
|
69
interface.go
69
interface.go
|
@ -5,17 +5,7 @@
|
|||
package xorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"xorm.io/xorm/caches"
|
||||
"xorm.io/xorm/contexts"
|
||||
"xorm.io/xorm/dialects"
|
||||
"xorm.io/xorm/log"
|
||||
"xorm.io/xorm/names"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
// Interface defines the interface which Engine, EngineGroup and Session will implementate.
|
||||
|
@ -74,61 +64,4 @@ type Interface interface {
|
|||
Where(interface{}, ...interface{}) *Session
|
||||
}
|
||||
|
||||
// EngineInterface defines the interface which Engine, EngineGroup will implementate.
|
||||
type EngineInterface interface {
|
||||
Interface
|
||||
|
||||
Before(func(interface{})) *Session
|
||||
Charset(charset string) *Session
|
||||
ClearCache(...interface{}) error
|
||||
Context(context.Context) *Session
|
||||
CreateTables(...interface{}) error
|
||||
DBMetas() ([]*schemas.Table, error)
|
||||
DBVersion() (*schemas.Version, error)
|
||||
Dialect() dialects.Dialect
|
||||
DriverName() string
|
||||
DropTables(...interface{}) error
|
||||
DumpAllToFile(fp string, tp ...schemas.DBType) error
|
||||
GetCacher(string) caches.Cacher
|
||||
GetColumnMapper() names.Mapper
|
||||
GetDefaultCacher() caches.Cacher
|
||||
GetTableMapper() names.Mapper
|
||||
GetTZDatabase() *time.Location
|
||||
GetTZLocation() *time.Location
|
||||
ImportFile(fp string) ([]sql.Result, error)
|
||||
MapCacher(interface{}, caches.Cacher) error
|
||||
NewSession() *Session
|
||||
NoAutoTime() *Session
|
||||
Prepare() *Session
|
||||
Quote(string) string
|
||||
SetCacher(string, caches.Cacher)
|
||||
SetConnMaxLifetime(time.Duration)
|
||||
SetColumnMapper(names.Mapper)
|
||||
SetTagIdentifier(string)
|
||||
SetDefaultCacher(caches.Cacher)
|
||||
SetLogger(logger interface{})
|
||||
SetLogLevel(log.LogLevel)
|
||||
SetMapper(names.Mapper)
|
||||
SetMaxOpenConns(int)
|
||||
SetMaxIdleConns(int)
|
||||
SetQuotePolicy(dialects.QuotePolicy)
|
||||
SetSchema(string)
|
||||
SetTableMapper(names.Mapper)
|
||||
SetTZDatabase(tz *time.Location)
|
||||
SetTZLocation(tz *time.Location)
|
||||
AddHook(hook contexts.Hook)
|
||||
ShowSQL(show ...bool)
|
||||
Sync(...interface{}) error
|
||||
Sync2(...interface{}) error
|
||||
StoreEngine(storeEngine string) *Session
|
||||
TableInfo(bean interface{}) (*schemas.Table, error)
|
||||
TableName(interface{}, ...bool) string
|
||||
UnMapType(reflect.Type)
|
||||
EnableSessionID(bool)
|
||||
}
|
||||
|
||||
var (
|
||||
_ Interface = &Session{}
|
||||
_ EngineInterface = &Engine{}
|
||||
_ EngineInterface = &EngineGroup{}
|
||||
)
|
||||
var _ Interface = &Session{}
|
||||
|
|
Loading…
Reference in New Issue