add bulk insert defaults
This commit is contained in:
committed by
Steve Chavez
parent
84b01dea99
commit
ea7a2bd531
@@ -875,6 +875,56 @@ To bulk insert JSON post an array of objects having all-matching keys
|
||||
]
|
||||
EOF
|
||||
|
||||
.. _bulk_insert_default:
|
||||
|
||||
Bulk Insert with Default Values
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Any missing columns in the payload will be inserted as ``null`` values. To use the ``DEFAULT`` column value instead, use the ``Prefer: missing=default`` header.
|
||||
|
||||
Having:
|
||||
|
||||
.. code-block:: postgres
|
||||
|
||||
create table foo (
|
||||
id bigint generated by default as identity primary key
|
||||
, bar text
|
||||
, baz int default 100
|
||||
);
|
||||
|
||||
A request:
|
||||
|
||||
.. code-block:: http
|
||||
|
||||
POST /foo?columns=id,bar,baz HTTP/1.1
|
||||
Content-Type: application/json
|
||||
Prefer: return=representation
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
[
|
||||
{ "bar": "val1"
|
||||
}
|
||||
, { "bar": "val2"
|
||||
, "baz": 15
|
||||
}
|
||||
]
|
||||
|
||||
Will result in:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
[
|
||||
{ "id": 1
|
||||
, "bar": "val1"
|
||||
, "baz": 100
|
||||
}
|
||||
, { "id": 2
|
||||
, "bar": "val2"
|
||||
, "baz": 15
|
||||
}
|
||||
]
|
||||
|
||||
.. _specify_columns:
|
||||
|
||||
Specifying Columns
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
Features
|
||||
--------
|
||||
|
||||
Horizontal Filtering
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
Inserts
|
||||
~~~~~~~
|
||||
|
||||
- New ``isdistinct`` :ref:`operator <operators>`. It is a direct translation of `IS DINTINCT FROM <https://www.postgresql.org/docs/current/functions-comparison.html#FUNCTIONS-COMPARISON-PRED-TABLE>`_.
|
||||
- New ``and/all`` :ref:`modifiers`.
|
||||
- New :ref:`bulk_insert_default`.
|
||||
|
||||
Resource Embedding
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
@@ -18,6 +17,12 @@ Resource Embedding
|
||||
- New :ref:`null_embed`.
|
||||
- New :ref:`empty_embed`.
|
||||
|
||||
Horizontal Filtering
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- New ``isdistinct`` :ref:`operator <operators>`. It is a direct translation of `IS DINTINCT FROM <https://www.postgresql.org/docs/current/functions-comparison.html#FUNCTIONS-COMPARISON-PRED-TABLE>`_.
|
||||
- New ``and/all`` :ref:`modifiers`.
|
||||
|
||||
OpenAPI
|
||||
~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user