Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: limitation when selecting related object that was modified by n after insert trigger #3254

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/references/api/resource_embedding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,21 @@ Response:
}
}

.. note::

Selecting a related object right after doing an insert may give unexpected results if said object was modified in a trigger.
For example, let's say there's an ``AFTER INSERT`` trigger on ``films`` that inserts a new record to ``technical_specs``.
Doing the same ``POST`` request as above, but selecting ``select=title,technical_spec(*)`` instead, it would return:

.. code-block:: json

{
"title": "127 hours",
"techinal_specs": null
}

Since PostgREST does the insertion and selection in a single query, the join is done before the changes are made to the related table, that's why ``technical_specs`` is empty.

.. _nested_embedding:

Nested Embedding
Expand Down