- Goal:
I would like to get the affected (inserted) identifier rows when using upsert with "Bulk upsert via a primary key" queries and similar that are created via GUI. While I can get this result writing the sql query myself, this is highly inconvenient.
Thank you.
-
Steps:
-
Details:
In case of "Bulk upsert via a primary key" I would expect to include "returning primary key column" at the end of the query, so I can get those IDs and work with them.
I don't want to write and maintain queries like this:
INSERT INTO
ec_products (
id,
brand_id,
name,
picture_url,
category_id,
description,
price
)
VALUES
(
coalesce(
{{ productId.value }},
nextval ('ec_products_product_id_seq')
),
{{ form2.data.brand_id }},
{{ form2.data.name }},
{{ form2.data.picture_url }},
{{ form2.data.category_id }},
{{ form2.data.description }},
{{ form2.data.price }}
) ON CONFLICT (id) DO
UPDATE
SET
picture = EXCLUDED.picture,
brand_id = EXCLUDED.brand_id,
name = EXCLUDED.name,
picture_url = EXCLUDED.picture_url,
category_id = EXCLUDED.category_id,
created_at = EXCLUDED.created_at,
description = EXCLUDED.description,
price = EXCLUDED.price,
updated_at = EXCLUDED.updated_at
RETURNING id;
-
Screenshots: