stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

Insertion to Table SET and MAP columns does not necessarily preserve order #1724

Closed hemidactylus closed 1 week ago

hemidactylus commented 1 week ago

(note: it should be verified that in C*, set and map collection columns are ordered (I think so, but must be double checked). Under this assumption...()

Insertion into such columns does not respect the order items are provided in the insert payload. E.g. for a set and a map:

"p_map_text_text":{"x":"YYY","p":"QQQ"},"p_set_int":[109,-43,0,111], ...

but then when reading (through Data API) I get

{-43, 0, 109, 111}, {"p":"QQQ", "x":"YYY"}

Also checking through CQL I can confirm the order on DB is the "wrong" one, i.e. those obtained when reading.

hemidactylus commented 1 week ago

Closing, I fooled myself into thinking those were ordered but it's not a user-provided order (rather by keys, unchangeable)

vkarpov15 commented 1 day ago

Just checking this means if you insert fields { name: 'test', age: 42 } as a map, you'll always get back the fields name, age in the original order? I tried to test this myself but ran into #1747