System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: 192bd3b5b24665d123751484c1d58ae4a8558200
Title: GetDouble handling of NaN
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: Data_Reader Resolution: Works_As_Designed
Last Modified: 2013-06-25 22:22:44
Version Found In: 1.0.86.0
User Comments:
anonymous added on 2013-06-25 12:51:58: (text/x-fossil-wiki)
If a field of a column of type REAL, is filled with NaN, the method <code> VerifyType(i, DbType.Double);</code> called by <code>GetDouble(int i)</code>  in SQLiteDataReader.cs throws an InvalidCastException.

<code> <PRE>   
CREATE TABLE dummy(
   id            integer PRIMARY KEY AUTOINCREMENT NOT NULL, 
   val           integer NOT NULL,
   val_critical  real  
);
</PRE>
</code>
<br/>

<code>
<PRE>
SQLiteDataReader reader = command.ExecuteReader();
  while (reader.Read())
    Console.WriteLine(reader.GetDouble(2)); //throws an exception if it reads NaN
</PRE>
</code>

<br/>
<b>possible solution:</b>
<br/>
Add following line to SQLiteDataReader.cs at line:353 in method VerifyType(int i, DbType typ): 
<br>
<code>if (typ == DbType.Double) return affinity;</code>

mistachkin added on 2013-06-25 20:57:05: (text/x-fossil-plain)
Also see ticket [e06c4caff3].

mistachkin added on 2013-06-25 22:22:44: (text/x-fossil-plain)
The type affinity for NaN is NULL, according to the SQLite core library.