@@ -11,6 +11,7 @@ import (
11
11
"fmt"
12
12
"github.com/xfali/gobatis"
13
13
"github.com/xfali/gobatis/common"
14
+ "github.com/xfali/gobatis/datasource"
14
15
"github.com/xfali/gobatis/executor"
15
16
"github.com/xfali/gobatis/factory"
16
17
"github.com/xfali/gobatis/logging"
@@ -84,14 +85,18 @@ func (exec *Executor) Query(ctx context.Context, result reflection.Object, sql s
84
85
return exec .exec .Query (ctx , result , sql , params ... )
85
86
}
86
87
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 )
89
90
}
90
91
91
92
func (f * Factory ) Close () error {
92
93
return f .fac .Close ()
93
94
}
94
95
96
+ func (f * Factory ) GetDataSource () datasource.DataSource {
97
+ return f .fac .GetDataSource ()
98
+ }
99
+
95
100
func (f * Factory ) CreateTransaction () transaction.Transaction {
96
101
return f .fac .CreateTransaction ()
97
102
}
@@ -106,13 +111,10 @@ func (f *Factory) LogFunc() logging.LogFunc {
106
111
}
107
112
108
113
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 ()
113
115
114
116
return & Executor {
115
- exec : executor . NewSimpleExecutor (transaction ),
117
+ exec : f . fac . CreateExecutor (transaction ),
116
118
log : f .LogFunc (),
117
119
modifier : SelectModifier (driver ),
118
120
}
0 commit comments