From 8ef5263b04828cb19f003d23919019c05784cee4 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 15 May 2025 17:42:13 -0500 Subject: [PATCH] docs: add warning for duplicate keys in spread --- docs/references/api/resource_embedding.rst | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/references/api/resource_embedding.rst b/docs/references/api/resource_embedding.rst index e9ecb531f..856048a22 100644 --- a/docs/references/api/resource_embedding.rst +++ b/docs/references/api/resource_embedding.rst @@ -1238,6 +1238,31 @@ You can order the correlated arrays explicitly. For example, to order by the fil } ] +.. warning:: + + Aliasing spreaded columns is recommended since JSON allows duplicate keys. Example: + + .. code-block:: bash + + curl --get "localhost:3000/projects" \ + -d "select=id,name,...clients(id,name)" + + .. code-block:: json + + [{"id":1,"name":"Windows 7","id":1,"name":"Microsoft"}, + {"id":2,"name":"Windows 10","id":1,"name":"Microsoft"}, + {"id":3,"name":"IOS","id":2,"name":"Apple"}, + {"id":4,"name":"OSX","id":2,"name":"Apple"}, + {"id":5,"name":"Orphan","id":null,"name":null}] + + This can be a problem in Javascript objects, since only the last duplicated key will be considered. To solve it do: + + .. code-block:: bash + + curl --get "localhost:3000/projects" \ + -d "select=id,name,...clients(client_id:id,client_name:name)" + + Multiple Spreads ----------------