Skip to content

Commit 3bf6969

Browse files
authored
for Config.cacheStore store PreparedStmtDB key (go-gorm#4149)
1 parent e34da30 commit 3bf6969

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gorm.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
"gorm.io/gorm/schema"
1313
)
1414

15+
// for Config.cacheStore store PreparedStmtDB key
16+
const preparedStmtDBKey = "preparedStmt"
17+
1518
// Config GORM config
1619
type Config struct {
1720
// GORM perform single create, update, delete operations in transactions by default to ensure database data integrity
@@ -161,7 +164,7 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
161164
Mux: &sync.RWMutex{},
162165
PreparedSQL: make([]string, 0, 100),
163166
}
164-
db.cacheStore.Store("preparedStmt", preparedStmt)
167+
db.cacheStore.Store(preparedStmtDBKey, preparedStmt)
165168

166169
if config.PrepareStmt {
167170
db.ConnPool = preparedStmt
@@ -224,7 +227,7 @@ func (db *DB) Session(config *Session) *DB {
224227
}
225228

226229
if config.PrepareStmt {
227-
if v, ok := db.cacheStore.Load("preparedStmt"); ok {
230+
if v, ok := db.cacheStore.Load(preparedStmtDBKey); ok {
228231
preparedStmt := v.(*PreparedStmtDB)
229232
tx.Statement.ConnPool = &PreparedStmtDB{
230233
ConnPool: db.Config.ConnPool,

0 commit comments

Comments
 (0)