Skip to content

Commit 4c448a1

Browse files
authored
fix: skip prepared in migrator (#109)
1 parent 4bf8c57 commit 4c448a1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

migrator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"regexp"
77
"strings"
88

9+
"github.com/jackc/pgx/v4"
910
"gorm.io/gorm"
1011
"gorm.io/gorm/clause"
1112
"gorm.io/gorm/migrator"
@@ -473,7 +474,12 @@ func (m Migrator) GetRows(currentSchema interface{}, table interface{}) (*sql.Ro
473474
if _, ok := currentSchema.(string); ok {
474475
name = fmt.Sprintf("%v.%v", currentSchema, table)
475476
}
476-
return m.DB.Session(&gorm.Session{}).Table(name).Limit(1).Rows()
477+
478+
return m.DB.Session(&gorm.Session{}).Table(name).Limit(1).Scopes(func(d *gorm.DB) *gorm.DB {
479+
// use simple protocol
480+
d.Statement.Vars = append(d.Statement.Vars, pgx.QuerySimpleProtocol(true))
481+
return d
482+
}).Rows()
477483
}
478484

479485
func (m Migrator) CurrentSchema(stmt *gorm.Statement, table string) (interface{}, interface{}) {

0 commit comments

Comments
 (0)