[odb-users] Storing NaN in the datadbase

Boris Kolpackov boris at codesynthesis.com
Wed Jul 18 06:13:07 EDT 2012

Hi Alexander,

Alexander A. Prokhorov <prokher at gmail.com> writes:

> class Value : public DbObject {
>   friend class odb::access;
>   double _value;
> };
> Everything is fine until Value::_value becomes NaN, when calling persist
> for such objects I got the following error: 'object already persistent'
> is it possible to store NaN's in database with odb?

Hm, according to this thread[1], SQLite converts NaNs to NULLs for some,
perhaps misguided, reason. To be consistent, I updated libodb-sqlite to
convert NULLs back to NaNs for consistency. So to make NaNs work you will
need to do two things:

1. Apply this patch to libodb-sqlite:


2. Enable NULLs for the members that store NaNs:

class Value : public DbObject {

  #pragma db null
  double _value;

[1] http://comments.gmane.org/gmane.comp.db.sqlite.general/73139


More information about the odb-users mailing list