diff --git a/src/database/sqlite/sqlite.cpp b/src/database/sqlite/sqlite.cpp index c2c7255..3da8aef 100644 --- a/src/database/sqlite/sqlite.cpp +++ b/src/database/sqlite/sqlite.cpp @@ -144,9 +144,12 @@ User SQLite::get_user(unsigned long id) int code = sqlite_exec(GET_USER_BY_ID, {{id}}, [&luser](sqlite3_stmt* stmt){ luser.acct = reinterpret_cast(sqlite3_column_text(stmt, 0)); - luser.display_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); - luser.bio = reinterpret_cast(sqlite3_column_int64(stmt, 2)); - luser.key = reinterpret_cast(sqlite3_column_text(stmt, 3)); + if (sqlite3_column_type(stmt, 1) == SQLITE_NULL) + luser.display_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); + if (sqlite3_column_type(stmt, 2) == SQLITE_NULL) + luser.bio = reinterpret_cast(sqlite3_column_int64(stmt, 2)); + if (sqlite3_column_type(stmt, 3) == SQLITE_NULL) + luser.key = reinterpret_cast(sqlite3_column_text(stmt, 3)); }); if (!code) @@ -166,9 +169,12 @@ User SQLite::get_user(const std::string& acct) int code = sqlite_exec(GET_USER_BY_ACCT, {acct}, [&luser](sqlite3_stmt* stmt){ luser.id = sqlite3_column_int64(stmt, 0); - luser.display_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); - luser.bio = reinterpret_cast(sqlite3_column_text(stmt, 2)); - luser.key = reinterpret_cast(sqlite3_column_text(stmt, 3)); + if (sqlite3_column_type(stmt, 1) == SQLITE_NULL) + luser.display_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); + if (sqlite3_column_type(stmt, 2) == SQLITE_NULL) + luser.bio = reinterpret_cast(sqlite3_column_text(stmt, 2)); + if (sqlite3_column_type(stmt, 3) == SQLITE_NULL) + luser.key = reinterpret_cast(sqlite3_column_text(stmt, 3)); }); if (!code)