How would i go about converting the following raw query to the new on_conflict
op?
#822
Answered
by
dantownsend
Drapersniper
asked this question in
Q&A
-
|
Beta Was this translation helpful? Give feedback.
Answered by
dantownsend
May 9, 2023
Replies: 1 comment 1 reply
-
Give this a go: from piccolo.querystring import QueryString
await Player.insert(
Player(...) # Whichever rows you want to upsert
).on_conflict(
action='DO UPDATE',
target=(Player.id, Player.bot), # assuming you have a composite unique constraint on these columns
values=[(Player.dj_roles, QueryString('array_cat(player.dj_roles, EXCLUDED.dj_roles)')]
) We're passing in the SQL for the value to update using |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Drapersniper
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Give this a go:
We're passing in the SQL for the value to update using
QueryString
. This isn't really documented anywhere, butQueryString
is the building block of queries internally.