evseevnn/php-cassandra-binary — pull request #45 by andreizet (2014-11-11 16:10:38+00:00)
Title: Resolved negative bigint issue

If in an int column (for example) a null value was inserted, that value
was read as null which was not correct.
If there were more columns after that one, everything was read as null,
even if values were actually there.
This issue happened for all types of numbers.

Follow this example to reproduce this issue:
------START------
------Create this table: ------
CREATE TABLE null_table_example(
id int,
col_str text,
col_int1 int,
col_int 2 bigint,
PRIMARY KEY (col_str)
);
------Run this insert: ------
insert into null_table_example (id, col_str, col_int1, col_int2) values (1, 'test1', null, 19);
------Run this query from php: ------
select * from null_table_example where col_str = 'test1';
------END------

It will return good values for "id" and "col_str" but "col_int1" and "col_int2" will be null even if there are numbers; Executing this query from DataStax or DBeaver will return the correct values (0 for "col_int1" and 19 for "col_int2");

I've added a method that returns a sake value for null items depending of the data type.
Also, when a null was read, the size of it's byte value was -1, thing that leaded into putting all the rest of the columns after the null one into that one until it was converter from bytes and it becomed null, see my commit of DataStream.php;

Thanks!