b9495d6179c88ccdbaac2b00ad0b17aabf23910e | Author: Piotr Dulikowski <piodul@scylladb.com>
| 2021-01-27 15:14:58+01:00
fix unmarshaling of last empty/nil field in tuple
Tuples are serialized as a sequence of pairs: length (32bit signed
number) + contents. If a tuple element is NULL, its length is set to -1
and it has empty contents.
However, if a tuple itself is NULL, the whole tuple is represented by
empty bytes. This special case is handled in the following way: when
trying to deserialize a tuple element and the length of remaining,
unparsed bytes not greater than 4, the tuple element is treated as if
it were NULL.
However, this check is incorrect - if the last element of the tuple is
represented as length = 0 and empty contents, then the check will cause
the driver to interpret it as NULL.
For example, for type tuple<int, text>, values (1, "") and (1, NULL)
will both be deserialized into (1, NULL).
This patch fixes this problem by adjusting the check - a tuple element
is considered NULL if there are _less_ than 4 bytes remaining.
745b2e381711f94e69cb1fea2758ebcf49d104f5 | Author: Piotr Dulikowski <piodul@scylladb.com>
| 2021-01-27 11:35:32+01:00
fix deserialization of nested tuples with nullable elements
Gocql supports deserialization of collections with tuples that hold
their elements as pointers - for example, list<tuple<string, string>>
can be deserialized into [][2]*string. Currently, the pointers in the
tuple are always set to a non-nil value, even if the tuple element was
NULL. This is inconsistent with non-nested column, for which gocql
allows to check if the column was NULL.
This patch fixes that, and now pointers in nested tuples are set to nil
if the corresponding column was NULL.
This patch also updates the TestMarshalTuple test, which expected the
old behavior.
e4931c4dd1990cd654f6a09c032d5672c53d5d14 | Author: Piotr Dulikowski <piodul@scylladb.com>
| 2021-01-27 10:45:44+01:00
tuple_test: check unmarshaled results in nested collection test
The TestTuple_NestedCollection is supposed to test marshaling and
unmarshaling of tuples nested in collections. It first writes a row and
then reads it, but it does not check that the unmarshaled value is the
same as the one used for writing. This commit adds this check to this
test.