scylladb / gocql

Package gocql implements a fast and robust ScyllaDB client for the Go programming language.
https://docs.scylladb.com/stable/using-scylla/drivers/cql-drivers/scylla-go-driver.html
BSD 3-Clause "New" or "Revised" License
189 stars 59 forks source link

Fix `int like` `cql types` with negative range, add error when processing `uint like` `go types` #306

Closed illia-li closed 1 month ago

illia-li commented 1 month ago

All int like cql types have negative range and positive range, but uint like go types have only positive range. For example, if cast -1 tinyint []byte("\xff") into uint like go types we got 255.

In the old marhsal/unmarshal functions (before the starts redesign), this problem was solved in different ways. Now marhsal/unmarshal functions (before the starts redesign), allow the processing with a negative range of the int like cql types for all uint like go types. But this can lead to problems due to the different DB and GO representations of the same values .

So, my suggest to leave only one way - stop the processing with a negative range of the int like cql types for all uint like go types.

sylwiaszunejko commented 1 month ago

Please add the information about what are you fixing in the commit message

dkropachev commented 1 month ago

@illia-li , @sylwiaszunejko , on some systems int/uint is 32 bytes, on some 64, we need considering this on marshal/unmarshal. And I think this PR is good place to start doing that.

dkropachev commented 1 month ago

I think we need first to come up with what is the "correct" behavior and then align code to it.

illia-li commented 1 month ago

Issue was created: #307 This PR will be closed until a decision is made on the #307 issue.