add: config to emit warning for legacy target names
Adds the `url_use_legacy_target_names` config. Enabled (default): * It allows using the resource name in filters, orders or limits when it has an alias, e.g. `table?select=alias:target(*)&target.id=eq.1` * Logs a WARNING with a hint to use the alias * Returns a Warning header in the response Disabled: * It returns an error, only the alias is allowed * No warnings returned This feature is deprecated
This commit is contained in:
committed by
Laurence Isla
parent
2fa8de4e52
commit
490d1dc5d3
@@ -1013,3 +1013,37 @@ server-unix-socket-mode
|
||||
.. code:: bash
|
||||
|
||||
server-unix-socket-mode = "660"
|
||||
|
||||
.. _url-use-legacy-target-names:
|
||||
|
||||
url-use-legacy-target-names
|
||||
---------------------------
|
||||
|
||||
=============== =================================
|
||||
**Type** Boolean
|
||||
**Default** True
|
||||
**Reloadable** Y
|
||||
**Environment** PGRST_URL_USE_LEGACY_TARGET_NAMES
|
||||
**In-Database** pgrst.url_use_legacy_target_names
|
||||
=============== =================================
|
||||
|
||||
When active, it allows using the the name of an embedded table in filters, orders or limits even if it has an alias:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
curl "http://localhost:3000/table?select=alias:target(*)&target.order=id" -i
|
||||
|
||||
.. code:: text
|
||||
|
||||
Warning: 299 PostgRESTv16 "Embedded resource was referenced by relation name even though it has an alias. This is deprecated and will stop working in a future release. Update `target` to `alias` in query string filters, orders or limits."
|
||||
[...]
|
||||
|
||||
Note that the response includes a deprecation message in the ``Warning`` header.
|
||||
This will also show in the PostgREST logs:
|
||||
|
||||
.. code::
|
||||
|
||||
28/May/2026:20:33:22 -0500: WARNING: Embedded resource was referenced by relation name even though it has an alias. This is deprecated and will stop working in a future release.
|
||||
28/May/2026:20:33:22 -0500: Update filters, orders or limits that use `target` to `alias` in `GET /table?select=alias:target(*)&target.order=id`
|
||||
|
||||
This feature will be removed in a future release, so you should start using the ``alias`` in these cases.
|
||||
|
||||
Reference in New Issue
Block a user