aboutsummaryrefslogtreecommitdiff
path: root/sqlite
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-18 12:07:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-18 12:07:19 +0200
commit4f59995242d894baa041a8171d420a18b43ceb8c (patch)
tree1d035db811adbe1ce6e6ec290cf2b3952936f511 /sqlite
parent3be0180445eaed554bf001d59e2cfa4389f94c10 (diff)
Convert NULLs to NaNs in SQLite for float and double
This makes it consistent with SQLite behavior which converts NaNs to NULLs.
Diffstat (limited to 'sqlite')
-rw-r--r--sqlite/types/driver.cxx2
-rw-r--r--sqlite/types/test.hxx16
2 files changed, 12 insertions, 6 deletions
diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx
index 0c19e75..1214d18 100644
--- a/sqlite/types/driver.cxx
+++ b/sqlite/types/driver.cxx
@@ -5,6 +5,7 @@
// Test SQLite type conversion.
//
+#include <limits> // std::numeric_limits
#include <memory> // std::auto_ptr
#include <cassert>
#include <iostream>
@@ -33,6 +34,7 @@ main (int argc, char* argv[])
o.bool_ = true;
o.integer_ = -123456;
o.real_ = 1.123;
+ o.nan_ = numeric_limits<double>::quiet_NaN ();
string long_str (2040, 'l');
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
index 6d9fc1c..7ed1a8c 100644
--- a/sqlite/types/test.hxx
+++ b/sqlite/types/test.hxx
@@ -29,24 +29,27 @@ struct object
#pragma db id
unsigned long id_;
- #pragma db type ("BOOL")
+ #pragma db type("BOOL")
bool bool_;
- #pragma db type ("INTEGER")
+ #pragma db type("INTEGER")
int integer_;
- #pragma db type ("REAL")
+ #pragma db type("REAL")
double real_;
- #pragma db type ("TEXT")
+ #pragma db type("REAL") null
+ double nan_;
+
+ #pragma db type("TEXT")
std::string text_;
- #pragma db type ("BLOB")
+ #pragma db type("BLOB")
std::vector<char> blob_;
// Test NULL value.
//
- #pragma db type ("TEXT") null
+ #pragma db type("TEXT") null
string_ptr null_;
bool
@@ -57,6 +60,7 @@ struct object
bool_ == y.bool_ &&
integer_ == y.integer_ &&
real_ == y.real_ &&
+ nan_ != nan_ &&
text_ == y.text_ &&
blob_ == y.blob_ &&
((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);