Fwd: Re[2]: [odb-users] odb compilation Visual Studio 2008 error

Boris Kolpackov boris at codesynthesis.com
Sat May 11 11:00:09 EDT 2013


Hi,

Please don't send multiple copies of the same question to the mailing
list. It won't make us reply faster. If any, it will have the exact
opposite effect.


Александр Кожевников <bioshocker at mail.ru> writes:

> #pragma db type("DATETIME")
> tm time_;

ODB doesn't provide a default mapping for struct tm. Generally, ODB
cannot "auto-magically" map any C++ type to any database type. The
only mappings that you can use are those that are documented in the
manual or those that you provided yourself. Also note that SQLite
doesn't have the DATETIME type.

So, in this case your options are (in the order of increasing 
difficulty):

1. Instead of struct tm, use a date-time type that is supported by
   ODB. For example, boost::posix_time::ptime from the Boost date-
   time library.

2. Provide your own implementation of struct tm to an SQLite type
   mapping. See this guide for details:

   http://www.codesynthesis.com/~boris/blog/2012/10/16/custom-cxx-to-database-type-mapping-in-odb/


> #pragma db type("NVARCHAR(36)")
> boost::uuids::uuid deviceId_;

The same problem here. ODB only supports mapping of Boost uuid to SQLite
BLOB. Also, SQLite doesn't have the NVARCHAR type. So your options here
are:

1. Use the default mapping for uuid.

2. Use a string instead of uuid if you want a text representation.

3. Provide your own mapping of uuid to TEXT.

Boris



More information about the odb-users mailing list