Remove the db-embed-default-join config

This commit is contained in:
Laurence Isla
2021-11-23 22:12:29 -05:00
committed by GitHub
parent c946f02607
commit 35d9b98bff
3 changed files with 46 additions and 39 deletions
+39 -12
View File
@@ -475,10 +475,16 @@ If the value filtered by the ``in`` operator has a double quote (``"``), you can
Here ``Quote:"`` and ``Backslash:\`` are percent-encoded values. Note that ``%5C`` is the percent-encoded backslash. Here ``Quote:"`` and ``Backslash:\`` are percent-encoded values. Note that ``%5C`` is the percent-encoded backslash.
.. code-block:: http .. tabs::
.. code-tab:: http
GET /marks?name=in.(%22Quote:%5C%22%22,%22Backslash:%5C%5C%22) HTTP/1.1 GET /marks?name=in.(%22Quote:%5C%22%22,%22Backslash:%5C%5C%22) HTTP/1.1
.. code-tab:: bash Curl
curl "http://localhost:3000/marks?name=in.(%22Quote:%5C%22%22,%22Backslash:%5C%5C%22)"
.. note:: .. note::
Some HTTP libraries might encode URLs automatically(e.g. :code:`axios`). In these cases you should use double quotes Some HTTP libraries might encode URLs automatically(e.g. :code:`axios`). In these cases you should use double quotes
@@ -992,10 +998,16 @@ Top Level Filtering
By default, embedded filters don't change the top level resource rows at all: By default, embedded filters don't change the top level resource rows at all:
.. code-block:: http .. tabs::
.. code-tab:: http
GET /films?select=title,actors(first_name,last_name)&actors.first_name=eq.Jehanne HTTP/1.1 GET /films?select=title,actors(first_name,last_name)&actors.first_name=eq.Jehanne HTTP/1.1
.. code-tab:: bash Curl
curl "http://localhost:3000/films?select=title,actors(first_name,last_name)&actors.first_name=eq.Jehanne
.. code-block:: json .. code-block:: json
[ [
@@ -1020,10 +1032,16 @@ By default, embedded filters don't change the top level resource rows at all:
In order to filter the top level rows you need to add ``!inner`` to the embedded resource. For instance, to get **only** the films that have an actor named ``Jehanne``: In order to filter the top level rows you need to add ``!inner`` to the embedded resource. For instance, to get **only** the films that have an actor named ``Jehanne``:
.. code-block:: http .. tabs::
.. code-tab:: http
GET /films?select=title,actors!inner(first_name,last_name)&actors.first_name=eq.Jehanne HTTP/1.1 GET /films?select=title,actors!inner(first_name,last_name)&actors.first_name=eq.Jehanne HTTP/1.1
.. code-tab:: bash Curl
curl "http://localhost:3000/films?select=title,actors!inner(first_name,last_name)&actors.first_name=eq.Jehanne"
.. code-block:: json .. code-block:: json
[ [
@@ -1038,12 +1056,6 @@ In order to filter the top level rows you need to add ``!inner`` to the embedded
} }
] ]
If you prefer to work with top level filtering as a default embedding behavior for PostgREST, set the :ref:`db-embed-default-join` configuration parameter to ``"inner"``. This way, you don't need to specify ``!inner`` on every request and, if you need the previous behavior, add ``!left`` to the embedding resource. For instance, this will not filter the films in any way:
.. code-block:: http
GET /films?select=title,actors!left(first_name,last_name)&actors.first_name=eq.Jehanne HTTP/1.1
.. _embedding_partitioned_tables: .. _embedding_partitioned_tables:
Embedding Partitioned Tables Embedding Partitioned Tables
@@ -1380,9 +1392,15 @@ Similarly to the **target**, the **hint** can be a **table name**, **foreign key
Hints also work alongside ``!inner`` if a top level filtering is needed. From the above example: Hints also work alongside ``!inner`` if a top level filtering is needed. From the above example:
.. code-block:: http .. tabs::
GET /orders?select=*,central_addresses!billing_address!inner(*)&central_addresses.code="AB1000" HTTP/1.1 .. code-tab:: http
GET /orders?select=*,central_addresses!billing_address!inner(*)&central_addresses.code=AB1000 HTTP/1.1
.. code-tab:: bash Curl
curl "http://localhost:3000/orders?select=*,central_addresses!billing_address!inner(*)&central_addresses.code=AB1000"
.. _insert_update: .. _insert_update:
@@ -1682,11 +1700,20 @@ To delete rows in a table, use the DELETE verb plus :ref:`h_filter`. For instanc
Deletions also support :code:`Prefer: return=representation` plus :ref:`v_filter`. Deletions also support :code:`Prefer: return=representation` plus :ref:`v_filter`.
.. code-block:: HTTP .. tabs::
.. code-tab:: http
DELETE /user?id=eq.1 HTTP/1.1 DELETE /user?id=eq.1 HTTP/1.1
Prefer: return=representation Prefer: return=representation
.. code-tab:: bash Curl
curl "http://localhost:3000/user?id=eq.1" -X DELETE \
-H "Prefer: return=representation"
.. code-block:: json
{"id": 1, "email": "johndoe@email.com"} {"id": 1, "email": "johndoe@email.com"}
.. warning:: .. warning::
-16
View File
@@ -50,7 +50,6 @@ db-channel-enabled Boolean True
db-prepared-statements Boolean True db-prepared-statements Boolean True
db-tx-end String commit db-tx-end String commit
db-config Boolean True db-config Boolean True
db-embed-default-join String left
db-use-legacy-gucs Boolean True db-use-legacy-gucs Boolean True
server-host String !4 server-host String !4
server-port Int 3000 server-port Int 3000
@@ -201,21 +200,6 @@ db-config
Enables the in-database configuration. Enables the in-database configuration.
.. _db-embed-default-join:
db-embed-default-join
---------------------
Determines the default embedding type between tables or views when none is specified in the request. For more info, see :ref:`embedding_top_level_filter`.
.. code:: bash
# Embeds using LEFT JOIN
db-embed-default-join = "left"
# Embeds using INNER JOIN
db-embed-default-join = "inner"
.. _db-use-legacy-gucs: .. _db-use-legacy-gucs:
db-use-legacy-gucs db-use-legacy-gucs
+2 -6
View File
@@ -14,12 +14,8 @@ Added
* Allow :ref:`embedding <embedding_partitioned_tables>`, UPSERT, INSERT with Location response, OPTIONS request and OpenAPI support for partitioned tables. * Allow :ref:`embedding <embedding_partitioned_tables>`, UPSERT, INSERT with Location response, OPTIONS request and OpenAPI support for partitioned tables.
|br| -- `@laurenceisla <https://github.com/laurenceisla>`_ |br| -- `@laurenceisla <https://github.com/laurenceisla>`_
* Allow filtering top-level resource based on embedded resources filters * Allow filtering top-level resource based on embedded resources filters. This is enabled by adding ``!inner`` to the embedded resource. See :ref:`embedding_top_level_filter`.
|br| -- `@steve-chavez <https://github.com/steve-chavez>`_
+ This is enabled by adding ``!inner`` to the embedded resource. See :ref:`embedding_top_level_filter`.
+ This behavior can be enabled by default by setting the :ref:`db-embed-default-join` to ``"inner"``.
-- `@steve-chavez <https://github.com/steve-chavez>`_
* Make GUC names for headers, cookies and jwt claims compatible with PostgreSQL v14. * Make GUC names for headers, cookies and jwt claims compatible with PostgreSQL v14.