Skip to content

Commit

Permalink
AutoMigrate fails with sql: expected 0 arguments, got 1 (#131)
Browse files Browse the repository at this point in the history
* AutoMigrate fails with `sql: expected 0 arguments, got 1` when `Statement.Vars` is null

* Update migrator.go

Co-authored-by: Jinzhu <wosmvp@gmail.com>
  • Loading branch information
pierre-borckmans and jinzhu committed Oct 7, 2022
1 parent 6145461 commit e6ed2df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion migrator.go
Expand Up @@ -528,7 +528,7 @@ func (m Migrator) GetRows(currentSchema interface{}, table interface{}) (*sql.Ro

return m.DB.Session(&gorm.Session{}).Table(name).Limit(1).Scopes(func(d *gorm.DB) *gorm.DB {
// use simple protocol
if !m.DB.PrepareStmt {
if !m.DB.PrepareStmt && len(d.Statement.Vars) != 0 {
d.Statement.Vars = append(d.Statement.Vars, pgx.QuerySimpleProtocol(true))
}
return d
Expand Down

0 comments on commit e6ed2df

Please sign in to comment.