Inconsistent/invalid data type mapping
Posted: Tue 21 Aug 2012 20:26
There seems to be an inconsistent or incorrect behavior with the data reader when there is a unsigned int column.
db table:
id int(10) unsigned
Now when the IDataRader is used:
long foo = (long)reader["id"];
The object shows as long, but when it is casted to long an invalid cast exception is thrown. I tried to cast it to uint, int, ulong as well but with the same result.
In earlier versions of dotConnect the object contained an int which then could be casted to an uint. I believe the decision to use a long is correct since the IDataReader interface does not support unsigned integers. However casting it to long should not throw an exception.
If the column data type is signed then it is correctly handled.
db table:
id int(10) unsigned
Now when the IDataRader is used:
long foo = (long)reader["id"];
The object shows as long, but when it is casted to long an invalid cast exception is thrown. I tried to cast it to uint, int, ulong as well but with the same result.
In earlier versions of dotConnect the object contained an int which then could be casted to an uint. I believe the decision to use a long is correct since the IDataReader interface does not support unsigned integers. However casting it to long should not throw an exception.
If the column data type is signed then it is correctly handled.