mirror of https://github.com/go-gorm/gorm.git
Switch pgx as default driver
This commit is contained in:
parent
3c03b6e527
commit
2d945a9641
|
@ -60,6 +60,7 @@ func (db *PreparedStmtDB) ExecContext(ctx context.Context, query string, args ..
|
|||
return stmt.ExecContext(ctx, args...)
|
||||
} else {
|
||||
db.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(db.Stmts, query)
|
||||
db.mux.Unlock()
|
||||
}
|
||||
|
@ -72,6 +73,7 @@ func (db *PreparedStmtDB) QueryContext(ctx context.Context, query string, args .
|
|||
return stmt.QueryContext(ctx, args...)
|
||||
} else {
|
||||
db.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(db.Stmts, query)
|
||||
db.mux.Unlock()
|
||||
}
|
||||
|
@ -84,6 +86,7 @@ func (db *PreparedStmtDB) QueryRowContext(ctx context.Context, query string, arg
|
|||
return stmt.QueryRowContext(ctx, args...)
|
||||
} else {
|
||||
db.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(db.Stmts, query)
|
||||
db.mux.Unlock()
|
||||
}
|
||||
|
@ -101,6 +104,7 @@ func (tx *PreparedStmtTX) ExecContext(ctx context.Context, query string, args ..
|
|||
return tx.Tx.Stmt(stmt).ExecContext(ctx, args...)
|
||||
} else {
|
||||
tx.PreparedStmtDB.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(tx.PreparedStmtDB.Stmts, query)
|
||||
tx.PreparedStmtDB.mux.Unlock()
|
||||
}
|
||||
|
@ -113,6 +117,7 @@ func (tx *PreparedStmtTX) QueryContext(ctx context.Context, query string, args .
|
|||
return tx.Tx.Stmt(stmt).QueryContext(ctx, args...)
|
||||
} else {
|
||||
tx.PreparedStmtDB.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(tx.PreparedStmtDB.Stmts, query)
|
||||
tx.PreparedStmtDB.mux.Unlock()
|
||||
}
|
||||
|
@ -125,6 +130,7 @@ func (tx *PreparedStmtTX) QueryRowContext(ctx context.Context, query string, arg
|
|||
return tx.Tx.Stmt(stmt).QueryRowContext(ctx, args...)
|
||||
} else {
|
||||
tx.PreparedStmtDB.mux.Lock()
|
||||
stmt.Close()
|
||||
delete(tx.PreparedStmtDB.Stmts, query)
|
||||
tx.PreparedStmtDB.mux.Unlock()
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ require (
|
|||
github.com/google/uuid v1.1.1
|
||||
github.com/jinzhu/now v1.1.1
|
||||
github.com/lib/pq v1.6.0
|
||||
gorm.io/driver/mysql v0.2.7
|
||||
gorm.io/driver/postgres v0.2.4
|
||||
gorm.io/driver/mysql v0.2.8
|
||||
gorm.io/driver/postgres v0.2.5
|
||||
gorm.io/driver/sqlite v1.0.8
|
||||
gorm.io/driver/sqlserver v0.2.4
|
||||
gorm.io/gorm v0.2.9
|
||||
gorm.io/gorm v0.2.19
|
||||
)
|
||||
|
||||
replace gorm.io/gorm => ../
|
||||
|
|
|
@ -54,7 +54,10 @@ func OpenTestConnection() (db *gorm.DB, err error) {
|
|||
if dbDSN == "" {
|
||||
dbDSN = "user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai"
|
||||
}
|
||||
db, err = gorm.Open(postgres.Open(dbDSN), &gorm.Config{})
|
||||
db, err = gorm.Open(postgres.New(postgres.Config{
|
||||
DSN: dbDSN,
|
||||
PreferSimpleProtocol: true,
|
||||
}), &gorm.Config{})
|
||||
case "sqlserver":
|
||||
// CREATE LOGIN gorm WITH PASSWORD = 'LoremIpsum86';
|
||||
// CREATE DATABASE gorm;
|
||||
|
|
Loading…
Reference in New Issue