Skip to content

Commit 4b890b8

Browse files
- separate out the interfaces
1 parent f0ccf55 commit 4b890b8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

db.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222
// connection is returned to DB's idle connection pool. The pool size
2323
// can be controlled with SetMaxIdleConns.
2424
type DB struct {
25-
// DB is the primary connection pool
26-
DB StdSQLDB
27-
// KillerPool is an optional (but recommended) secondary connection pool.
25+
// DB is the primary connection pool (i.e. *stdSql.DB).
26+
DB StdSQLDBExtra
27+
// KillerPool is an optional (but recommended) secondary connection pool (i.e. *stdSql.DB).
2828
// If provided, it is used to fire KILL signals.
29-
KillerPool StdSQLDB
29+
KillerPool StdSQLDBExtra
3030
}
3131

3232
// Begin starts a transaction. The default isolation level is dependent on

interfaces.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ import (
99
"time"
1010
)
1111

12+
// StdSQLLegacy will potentially be removed in Go 2.
13+
type StdSQLLegacy interface {
14+
Exec(query string, args ...interface{}) (stdSql.Result, error)
15+
Prepare(query string) (*stdSql.Stmt, error)
16+
Query(query string, args ...interface{}) (*stdSql.Rows, error)
17+
QueryRow(query string, args ...interface{}) *stdSql.Row
18+
}
19+
1220
// StdSQLCommon is the interface that allows query and exec interactions with a database.
1321
type StdSQLCommon interface {
14-
Exec(query string, args ...interface{}) (stdSql.Result, error)
22+
StdSQLLegacy
1523
ExecContext(ctx context.Context, query string, args ...interface{}) (stdSql.Result, error)
16-
Prepare(query string) (*stdSql.Stmt, error)
1724
PrepareContext(ctx context.Context, query string) (*stdSql.Stmt, error)
18-
Query(query string, args ...interface{}) (*stdSql.Rows, error)
1925
QueryContext(ctx context.Context, query string, args ...interface{}) (*stdSql.Rows, error)
20-
QueryRow(query string, args ...interface{}) *stdSql.Row
2126
QueryRowContext(ctx context.Context, query string, args ...interface{}) *stdSql.Row
2227
}
2328

@@ -30,7 +35,11 @@ type StdSQLDB interface {
3035
Begin() (*stdSql.Tx, error)
3136
BeginTx(ctx context.Context, opts *stdSql.TxOptions) (*stdSql.Tx, error)
3237
Close() error
38+
}
3339

40+
// StdSQLDBExtra is the interface that directly maps to a *stdSql.DB.
41+
type StdSQLDBExtra interface {
42+
StdSQLDB
3443
Driver() driver.Driver
3544
SetConnMaxLifetime(d time.Duration)
3645
SetMaxIdleConns(n int)

0 commit comments

Comments
 (0)