diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-10-02 19:51:41 -0500 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-10-02 19:51:41 -0500 |
commit | f7eede23de6f78b2b33b477b2b4c5451141825d5 (patch) | |
tree | d698a92272b8e4a8428b82d9a21f3e98ed267a6d /source/fud_sqlite.cpp | |
parent | 32c722d50943bbdeba65a77d5e94f8692cf75f3c (diff) |
Add setup for coverage and cppcheck.
Diffstat (limited to 'source/fud_sqlite.cpp')
-rw-r--r-- | source/fud_sqlite.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/fud_sqlite.cpp b/source/fud_sqlite.cpp index f573f1c..e07523d 100644 --- a/source/fud_sqlite.cpp +++ b/source/fud_sqlite.cpp @@ -58,6 +58,8 @@ SqliteDb& SqliteDb::operator=(SqliteDb&& rhs) m_nameValid = rhs.m_nameValid; m_dbHandle = rhs.m_dbHandle; m_errorCode = rhs.m_errorCode; + m_mode = rhs.m_mode; + m_extraFlags = rhs.m_extraFlags; rhs.m_nameValid = false; rhs.m_dbHandle = nullptr; @@ -94,9 +96,9 @@ FudStatus SqliteDb::exec( } char* errorMsgPtr = nullptr; - char** errorMsgPtrAddress = &errorMsgPtr; - if (errorMessage == nullptr) { - errorMsgPtrAddress = nullptr; + char** errorMsgPtrAddress = nullptr; + if (errorMessage != nullptr) { + errorMsgPtrAddress = &errorMsgPtr; } m_errorCode = sqlite3_exec( @@ -106,6 +108,10 @@ FudStatus SqliteDb::exec( context, errorMsgPtrAddress); + if (errorMessage != nullptr) { + *errorMessage = String{errorMsgPtr}; + } + return m_errorCode == SQLITE_OK ? FudStatus::Success : FudStatus::Failure; } @@ -126,10 +132,10 @@ int SqliteDb::open() return sqlite3_open_v2(m_name.c_str(), &m_dbHandle, static_cast<int>(m_mode) | m_extraFlags, nullptr); } -Result<SqliteStatement, FudStatus> SqliteDb::prepare(const String& dql) +Result<SqliteStatement, FudStatus> SqliteDb::prepare(const String& sql) { using RetType = Result<SqliteStatement, FudStatus>; - SqliteStatement preparedStatement{*this, dql}; + SqliteStatement preparedStatement{*this, sql}; if (!preparedStatement.valid() || preparedStatement.status() != FudStatus::Success) { m_errorCode = preparedStatement.errorCode(); |