The driver should submit the request to Postgresql in this final form:
update portfolios p set votes = s.votes from unnest(array[(5, 1), (15, 1), (25, 2)]) s (votes int, id int) where p.id = s.id
So pass this request to the driver:
update portfolios p set votes = s.votes from unnest($1) s (votes int, id int) where p.id = s.id
with the corresponding array as a parameter.
Please note: if you build the string yourself, instead of letting the driver do this, you will be vulnerable to SQL injection.
source share