NULL check Sqlite3
FossilOrigin-Name: 48a6e0f0b25381529d6c52ecf5397a8e2ed0c16bf726cd795a0ffee3fd469e8c
This commit is contained in:
parent
4db2562cb8
commit
87a5c180d7
1 changed files with 12 additions and 6 deletions
|
@ -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<const char*>(sqlite3_column_text(stmt, 0));
|
||||
luser.display_name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
|
||||
luser.bio = reinterpret_cast<const char*>(sqlite3_column_int64(stmt, 2));
|
||||
luser.key = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
|
||||
if (sqlite3_column_type(stmt, 1) == SQLITE_NULL)
|
||||
luser.display_name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
|
||||
if (sqlite3_column_type(stmt, 2) == SQLITE_NULL)
|
||||
luser.bio = reinterpret_cast<const char*>(sqlite3_column_int64(stmt, 2));
|
||||
if (sqlite3_column_type(stmt, 3) == SQLITE_NULL)
|
||||
luser.key = reinterpret_cast<const char*>(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<const char*>(sqlite3_column_text(stmt, 1));
|
||||
luser.bio = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
|
||||
luser.key = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
|
||||
if (sqlite3_column_type(stmt, 1) == SQLITE_NULL)
|
||||
luser.display_name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1));
|
||||
if (sqlite3_column_type(stmt, 2) == SQLITE_NULL)
|
||||
luser.bio = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
|
||||
if (sqlite3_column_type(stmt, 3) == SQLITE_NULL)
|
||||
luser.key = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
|
||||
});
|
||||
|
||||
if (!code)
|
||||
|
|
Loading…
Reference in a new issue