Remove method SetPool() in favour of sql package's builtin method, Use

it like this `db.DB().SetMaxIdleConns(10)`

So gorm don't need to care about compatibility problems, and you could
use latest `database/sql` features from latest releases without waiting gorm's support
This commit is contained in:
Jinzhu 2013-12-04 14:33:35 +08:00
parent 90a4581a7f
commit e6a2273114
3 changed files with 1 additions and 8 deletions

View File

@ -91,7 +91,7 @@ func init() {
// CREATE DATABASE 'gorm'; // CREATE DATABASE 'gorm';
// GRANT ALL ON gorm.* TO 'gorm'@'localhost'; // GRANT ALL ON gorm.* TO 'gorm'@'localhost';
fmt.Println("testing mysql...") fmt.Println("testing mysql...")
db, err = Open("mysql", "gorm:gorm@/gorim?charset=utf8&parseTime=True") db, err = Open("mysql", "gorm:gorm@/gorm?charset=utf8&parseTime=True")
case "sqlite": case "sqlite":
fmt.Println("testing sqlite3...") fmt.Println("testing sqlite3...")
db, err = Open("sqlite3", "/tmp/gorm.db") db, err = Open("sqlite3", "/tmp/gorm.db")

View File

@ -31,12 +31,6 @@ func (s *DB) DB() *sql.DB {
return s.db.(*sql.DB) return s.db.(*sql.DB)
} }
func (s *DB) SetPool(n int) {
if db, ok := s.parent.db.(sqlDb); ok {
db.SetMaxIdleConns(n)
}
}
func (s *DB) SetTagIdentifier(str string) { func (s *DB) SetTagIdentifier(str string) {
s.parent.tagIdentifier = str s.parent.tagIdentifier = str
} }

1
sql.go
View File

@ -11,7 +11,6 @@ type sqlCommon interface {
type sqlDb interface { type sqlDb interface {
Begin() (*sql.Tx, error) Begin() (*sql.Tx, error)
SetMaxIdleConns(n int)
} }
type sqlTx interface { type sqlTx interface {