SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.41k stars 477 forks source link

Sqlite3 dt_date usage #969

Open mmaurus opened 2 years ago

mmaurus commented 2 years ago

Creating a table using the generic code

soci::ddl_type ddl = db.create_table(name);
ddl.column("TIMESTAMP", soci::dt_date)("not null");

a new table is created with the column type INTEGER instead of the expected type "DATE".

When querying data from this column the following code an std::bad_cast error is thrown:

std::tm timestamp;
statement st = (db.prepare << "select TIMESTAMP from name, into(timestamp));
st.execute();

This might be due to this part of code: https://github.com/SOCI/soci/blob/master/include/soci/sqlite3/soci-sqlite3.h#L319 I would expect for "dt_date" a mapping to "date" or something similar.

The corresponding std::tm test for sqlite3 succeeds, because it is not using ddl_type but rather a direct sql command for creating the table: https://github.com/SOCI/soci/blob/master/tests/sqlite3/test-sqlite3.cpp#L379