From 3d734c44cf2ef4437a3596fab891dc0db31d94ca Mon Sep 17 00:00:00 2001 From: Paulo Vieira Date: Sat, 9 Mar 2019 22:25:05 +0000 Subject: [PATCH] clarify the usage of upsert when the table uses a surrogate key --- api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.rst b/api.rst index 32e5d1a44..41b7f75e2 100644 --- a/api.rst +++ b/api.rst @@ -968,7 +968,7 @@ You can make an UPSERT with :code:`POST` and the :code:`Prefer: resolution=merge { "id": 3, "name": "New employee 3", "salary": 50000 } ] -UPSERT operates based on the primary key columns, you must specify all of them. You can also choose to ignore the duplicates with :code:`Prefer: resolution=ignore-duplicates`. +UPSERT operates based on the primary key columns, you must specify all of them. You can also choose to ignore the duplicates with :code:`Prefer: resolution=ignore-duplicates`. UPSERT works best when the primary key is natural, but it's also possible to use it if the primary key is surrogate (example: "id serial primary key"). For more details read `this issue `_. A single row UPSERT can be done by using :code:`PUT` and filtering the primary key columns with :code:`eq`: