jmoiron / sqlx

general purpose extensions to golang's database/sql
http://jmoiron.github.io/sqlx/
MIT License
15.95k stars 1.07k forks source link

use NamedExec to batch update,but got error #810

Open liwilljinx opened 2 years ago

liwilljinx commented 2 years ago

modifyRulesSql := update public."casbin_rule_auth" set v2=:v2 where v0=:v0 and v1=:v1 _, err = db.NamedExec(testSql, roleAuthPs) when i use update, got this error: pq: got 15 parameters but the statement requires 3

testSql := insert into public."casbin_rule_auth"(p_type, v0, v1, v2) values('p', :v0, :v1, :v2) _, err = db.NamedExec(testSql, roleAuthPs) if i use insert, it can work

how can i solve this problem.i want to batch update,how can i do?

JruiPRXD commented 2 years ago

请问解决了吗

liwilljinx commented 2 years ago

请问解决了吗

image 你可以试一下这个方法,796条issue,但是我没有成功。。。只能循环更新了