Skip to content

Commit 99c5f1c

Browse files
committed
适配gobatis v0.1.1+
1 parent 2bd6e64 commit 99c5f1c

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/xfali/pagehelper
22

33
go 1.12
44

5-
require github.com/xfali/gobatis v0.0.5
5+
require github.com/xfali/gobatis v0.1.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ github.com/xfali/gobatis v0.0.4 h1:rBR8m18xMQAL58jDIr+i9zj8RYC+Mfa9rOw4ZB3shf0=
44
github.com/xfali/gobatis v0.0.4/go.mod h1:hXP3PcXMSYpYFHQejG04qQjSQJtrt8jWpslftkUMBrg=
55
github.com/xfali/gobatis v0.0.5 h1:JFpkn0Gihxocc3ZXqKRv4p5q1JiIeRanL0rTdZRZX0Q=
66
github.com/xfali/gobatis v0.0.5/go.mod h1:nAml9g3T+vn1qDF5nLzSQM9t4l9Fu56GYQ33bYp5Mok=
7+
github.com/xfali/gobatis v0.1.1 h1:2F1q6bylWG9bc05/OApDGSSrocT/lKrO1U0WclvgcU0=
8+
github.com/xfali/gobatis v0.1.1/go.mod h1:nAml9g3T+vn1qDF5nLzSQM9t4l9Fu56GYQ33bYp5Mok=

orm.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"github.com/xfali/gobatis"
1313
"github.com/xfali/gobatis/common"
14+
"github.com/xfali/gobatis/datasource"
1415
"github.com/xfali/gobatis/executor"
1516
"github.com/xfali/gobatis/factory"
1617
"github.com/xfali/gobatis/logging"
@@ -84,14 +85,18 @@ func (exec *Executor) Query(ctx context.Context, result reflection.Object, sql s
8485
return exec.exec.Query(ctx, result, sql, params...)
8586
}
8687

87-
func (f *Factory) InitDB() error {
88-
return f.fac.InitDB()
88+
func (f *Factory) Open(source datasource.DataSource) error {
89+
return f.fac.Open(source)
8990
}
9091

9192
func (f *Factory) Close() error {
9293
return f.fac.Close()
9394
}
9495

96+
func (f *Factory) GetDataSource() datasource.DataSource {
97+
return f.fac.GetDataSource()
98+
}
99+
95100
func (f *Factory) CreateTransaction() transaction.Transaction {
96101
return f.fac.CreateTransaction()
97102
}
@@ -106,13 +111,10 @@ func (f *Factory) LogFunc() logging.LogFunc {
106111
}
107112

108113
func (f *Factory) CreateExecutor(transaction transaction.Transaction) executor.Executor {
109-
driver := ""
110-
if defaultFac, ok := f.fac.(*factory.DefaultFactory); ok {
111-
driver = defaultFac.DataSource.DriverName()
112-
}
114+
driver := f.fac.GetDataSource().DriverName()
113115

114116
return &Executor{
115-
exec: executor.NewSimpleExecutor(transaction),
117+
exec: f.fac.CreateExecutor(transaction),
116118
log: f.LogFunc(),
117119
modifier: SelectModifier(driver),
118120
}

0 commit comments

Comments
 (0)