Skip to content

Commit e6ed2df

Browse files
AutoMigrate fails with sql: expected 0 arguments, got 1 (#131)
* AutoMigrate fails with `sql: expected 0 arguments, got 1` when `Statement.Vars` is null * Update migrator.go Co-authored-by: Jinzhu <wosmvp@gmail.com>
1 parent 6145461 commit e6ed2df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

migrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ func (m Migrator) GetRows(currentSchema interface{}, table interface{}) (*sql.Ro
528528

529529
return m.DB.Session(&gorm.Session{}).Table(name).Limit(1).Scopes(func(d *gorm.DB) *gorm.DB {
530530
// use simple protocol
531-
if !m.DB.PrepareStmt {
531+
if !m.DB.PrepareStmt && len(d.Statement.Vars) != 0 {
532532
d.Statement.Vars = append(d.Statement.Vars, pgx.QuerySimpleProtocol(true))
533533
}
534534
return d

0 commit comments

Comments
 (0)