I have an application that utilizes NHibernate to handle database functionality. Now I have a table with a column mapped as a float. NHibernate created the table in the MySql database, and I have validated the column to be "FLOAT" as well. NOTE: There is not FLOAT(M<,D) precision defined in the column, it's just "FLOAT".
Partial SQL table create statement:
CREATE TABLE `X` (
`TresholdLow` float NOT NULL,
Now when I try to insert the domain model (POCO) with a float property of value 5.46, for example, all goes well, so the domain model is mapped properly and is working.
But when I try to insert the domain model with the property set at float.MinValue
resulting in a value of 3.40282347E+38 I get the following error:
ERROR 1264: Out of range value for column 'TresholdLow' at row 1
I think it might have to do something with the following. This is input (marked by ?) and output of the immediate window in Visual Studio:
?float.MinValue.ToString();
"-3.402823E+38"
?float.MinValue
-3.40282347E+38
The first value IS accepted by MySQL, the latter ISN'T!!
How do I work around this issue? Practically it won't be a problem, but theoretically it is not so nice to have a database float column not accepting all possible float values coming from the application that is storing the data.