Project

General

Profile

« Previous | Next » 

Revision 7080e544

Added by David Sorber over 9 years ago

Updating the templatized query PoC to support the case where integer or float type columns return NULL and should be treated as 0 and 0.0 respectively.

View differences:

software/sqlite_poc/DBManager.cc
// Helper function for int64_t type
void get_value(int64_t& val, int idx, sqlite3_stmt* stmt)
{
if (sqlite3_column_type(stmt, idx) != SQLITE_INTEGER)
if (sqlite3_column_type(stmt, idx) == SQLITE_INTEGER)
{
val = sqlite3_column_int64(stmt, idx);
}
else if (sqlite3_column_type(stmt, idx) == SQLITE_NULL)
{
val = 0;
}
else
{
assert(false);
}
val = sqlite3_column_int64(stmt, idx);
}
// Helper function for double type
void get_value(double& val, int idx, sqlite3_stmt* stmt)
{
if (sqlite3_column_type(stmt, idx) != SQLITE_FLOAT)
if (sqlite3_column_type(stmt, idx) == SQLITE_FLOAT)
{
assert(false);
val = sqlite3_column_double(stmt, idx);
}
else if (sqlite3_column_type(stmt, idx) == SQLITE_NULL)
{
val = 0.0;
}
else
{
assert(false);
}
val = sqlite3_column_double(stmt, idx);
}
// Helper function for string type

Also available in: Unified diff