All int likecql types have negative range and positive range, but uint like go types have only positive range.
For example, if cast -1tinyint[]byte("\xff") into uint likego types we got 255.
In the old marhsal/unmarshal functions (before the starts redesign), this problem was solved in different ways.
So, my suggest to leave only one way, because if have different ways its not clear. Moreover, this can lead to unexpected consequences, not at the time of testing, but at the moment when the value ofuintfalls into the negative range ofcql type`.
Way 1 - deny any processing with negative range of int likecql types. This way means:
On marshal:
1.1. For uint like go types with less bitsize then the cql type - free encoding into positive range of the cql type
1.2. For uint like go types with same or bigger bitsize then the cql type - encoding only if value of the uintgo type in the positive range of the cql type.
On unmarshal:
2.1. For all uint like go types - encoding only if the data from DB in the positive range and in the range of the uintgo type.
Way 2 - allow processing with negative range of int likecql types. This way means:
On marshal:
1.1. For uint like go types with less bitsize then the cql type - free encoding into positive range of the cql type
1.1. For uint like go types with same bitsize then the cql type - free encoding into all range of the cql type
1.2. For uint like go types with bigger bitsize then the cql type - encoding only if value of the uintgo type in the range of the cql type.
On unmarshal:
2.1. For all uint like go types - encoding only if the data from DB in the range of the uintgo type.
In relation to DB users can be sorted into 2 groups:
Users who use DB only with GO.
Users who use DB not only with GO.
For users from group #1 all two ways will be acceptable, but they will not be able to processing with full range of the int likecql types from the box.
At the same time, they will always have the opportunity to make their own marshal/unmarshall functions.
For users from group #2 only way 1 will be acceptable, because way 2 can lead to problems due to the different DB and GO representations of the same values.
And it may turn out that they will find out only after a while.
So, my suggest to leave only one way - deny the processing with a negative range of the int like cql types for all uint likego types.
All
int like
cql types
havenegative
range andpositive
range, butuint
likego types
have onlypositive
range. For example, if cast-1
tinyint
[]byte("\xff")
intouint like
go types
we got255
.In the old marhsal/unmarshal functions (before the starts redesign), this problem was solved in different ways. So, my suggest to leave only one way, because if have different ways it
s not clear. Moreover, this can lead to unexpected consequences, not at the time of testing, but at the moment when the value of
uintfalls into the negative range of
cql type`.Way 1 - deny any processing with negative range of
int like
cql types
. This way means:uint like go types
with less bitsize then thecql type
- free encoding into positive range of thecql type
1.2. Foruint like go types
with same or bigger bitsize then thecql type
- encoding only if value of theuint
go type
in the positive range of thecql type
.uint like go types
- encoding only if the data fromDB
in the positive range and in the range of theuint
go type
.Way 2 - allow processing with negative range of
int like
cql types
. This way means:uint like go types
with less bitsize then thecql type
- free encoding into positive range of thecql type
1.1. Foruint like go types
with same bitsize then thecql type
- free encoding into all range of thecql type
1.2. Foruint like go types
with bigger bitsize then thecql type
- encoding only if value of theuint
go type
in the range of thecql type
.uint like go types
- encoding only if the data fromDB
in the range of theuint
go type
.In relation to
DB
users can be sorted into 2 groups:DB
only withGO
.DB
not only withGO
.For users from
group #1
all two ways will be acceptable, but they will not be able to processing with full range of theint like
cql types
from the box. At the same time, they will always have the opportunity to make their own marshal/unmarshall functions.For users from
group #2
onlyway 1
will be acceptable, becauseway 2
can lead to problems due to the differentDB
andGO
representations of the same values. And it may turn out that they will find out only after a while.So, my suggest to leave only one way - deny the processing with a negative range of the
int
likecql types
for alluint like
go types
.