fix sqlite bug and add SetConnMaxLifetime
This commit is contained in:
parent
942887dea0
commit
c01da1b710
|
@ -14,10 +14,6 @@ import (
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
// func init() {
|
|
||||||
// RegisterDialect("sqlite3", &sqlite3{})
|
|
||||||
// }
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sqlite3ReservedWords = map[string]bool{
|
sqlite3ReservedWords = map[string]bool{
|
||||||
"ABORT": true,
|
"ABORT": true,
|
||||||
|
|
|
@ -195,6 +195,11 @@ func (engine *Engine) SetMaxIdleConns(conns int) {
|
||||||
engine.db.SetMaxIdleConns(conns)
|
engine.db.SetMaxIdleConns(conns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
|
||||||
|
func (engine *Engine) SetConnMaxLifetime(d time.Duration) {
|
||||||
|
engine.db.SetConnMaxLifetime(d)
|
||||||
|
}
|
||||||
|
|
||||||
// SetDefaultCacher set the default cacher. Xorm's default not enable cacher.
|
// SetDefaultCacher set the default cacher. Xorm's default not enable cacher.
|
||||||
func (engine *Engine) SetDefaultCacher(cacher core.Cacher) {
|
func (engine *Engine) SetDefaultCacher(cacher core.Cacher) {
|
||||||
engine.Cacher = cacher
|
engine.Cacher = cacher
|
||||||
|
|
|
@ -7,6 +7,7 @@ package xorm
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -1117,3 +1118,17 @@ func TestSingleAutoIncrColumn(t *testing.T) {
|
||||||
_, err := testEngine.Insert(&Account{})
|
_, err := testEngine.Insert(&Account{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompositePK(t *testing.T) {
|
||||||
|
type TaskSolution struct {
|
||||||
|
UID string `xorm:"notnull pk UUID 'uid'"`
|
||||||
|
TID string `xorm:"notnull pk UUID 'tid'"`
|
||||||
|
Created time.Time `xorm:"created"`
|
||||||
|
Updated time.Time `xorm:"updated"`
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NoError(t, prepareEngine())
|
||||||
|
assertSync(t, new(TaskSolution))
|
||||||
|
|
||||||
|
assert.NoError(t, testEngine.Sync2(new(TaskSolution)))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue