-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Batch update support #796
Comments
The syntax should simply be: UPDATE rows AS r
SET r.column1 = v.column1,
r.column2 = v.column2
FROM (VALUES
(:id, :column1, :column2)
) AS v(id, column1, column2)
WHERE r.id = v.id However, this doesn't currently work in Line 227 in 92bfa36
This was discussed by @QuangTung97 and @w1ck3dg0ph3r when it was initially implemented https://github.com/jmoiron/sqlx/pull/734/files#r632982543 and possible changes required to mitigate this. Also worth noting is that update doesn't automatically coerce type https://www.postgresql.org/docs/14/sql-values.html and you might have to be explicitly cast the types. More info on this can be found in the comments on answer https://stackoverflow.com/a/18799497.
A final caveat is the casting using |
For anyone else who gets here, another temp workaround until this is fixed is doing something like:
|
According to this comment , on a named batch update every variable after the |
Does sqlx support batch update query? For example, like the one below:
If so, how one should use it correctly?
The text was updated successfully, but these errors were encountered: