添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gorm version v1.20.1

// Exec execute raw sql
func (db *DB) Exec(sql string, values ...interface{}) (tx *DB)

In the Exec function, if the sql parameter contains @,? characters, etc., and the values parameter is not passed in, the Exec function executes an error.

example:

query := `UPDATE "1_buffer_data" SET value = '@1Condition?' WHERE "id" = '1';`
err := DBConn.Debug().Exec(query).Error
if err != nil {
   return err
// Output:
// runtime error: index out of range [0] with length 0