Skip to content

Commit 5206319

Browse files
committed
docs: add warning for duplicate keys in spread
1 parent 10e31c4 commit 5206319

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/references/api/resource_embedding.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,31 @@ You can order the correlated arrays explicitly. For example, to order by the fil
12381238
}
12391239
]
12401240
1241+
.. warning::
1242+
1243+
Aliasing spreaded columns is recommended since JSON allows duplicate keys. Example:
1244+
1245+
.. code-block:: bash
1246+
1247+
curl --get "localhost:3000/projects" \
1248+
-d "select=id,name,...clients(id,name)"
1249+
1250+
.. code-block:: json
1251+
1252+
[{"id":1,"name":"Windows 7","id":1,"name":"Microsoft"},
1253+
{"id":2,"name":"Windows 10","id":1,"name":"Microsoft"},
1254+
{"id":3,"name":"IOS","id":2,"name":"Apple"},
1255+
{"id":4,"name":"OSX","id":2,"name":"Apple"},
1256+
{"id":5,"name":"Orphan","id":null,"name":null}]
1257+
1258+
This can be a problem in Javascript objects, since only the last duplicated key will be considered. To solve it do:
1259+
1260+
.. code-block:: bash
1261+
1262+
curl --get "localhost:3000/projects" \
1263+
-d "select=id,name,...clients(client_id:id,client_name:name)"
1264+
1265+
12411266
Multiple Spreads
12421267
----------------
12431268

0 commit comments

Comments
 (0)