vtkMySQLQuery incorrectly returning non NULL values in certain circumstances
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
When querying a table which has columns which may be null this class returns non-null values when it shouldn't. For instance, for the table:
CREATE TABLE myTable ( myIntValue int DEFAULT NULL, myFloatValue float DEFAULT NULL )
columns myIntValue and myFloatValue may be set to null, but when reading these values using vtkMySQLQuery the values 0 and 0.0 are returned instead of NULL.
The reason is found in vtkMySQLQuery::DataValue Specifically, in the switch statement there are several return statements which do the following:
return vtkVariant(base.ToInt());
When the value is NULL the variable "base" is correctly set to an un-initialized state. Calling ToInt() returns 0 even if it is not a valid number (NULL), so instead this line should read:
return base.IsValid() ? vtkVariant(base.ToInt()) : base;
The same could be applied for long, floats and doubles.