mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Fix #156 Misleading error message in exception from Statement::exec
Fix #199 the problem is that tryExecuteStep returns SQLITE_MISUSE when it was not used properly. Since this is set manually this is not the error state of the statement, so when checking the error message of the statement there obviously is none, since there was no error. fixes this problem by checking whether the error code is the same as the error state of the statement
This commit is contained in:
commit
08a73ce90b
@ -259,9 +259,16 @@ bool Statement::executeStep()
|
|||||||
{
|
{
|
||||||
const int ret = tryExecuteStep();
|
const int ret = tryExecuteStep();
|
||||||
if ((SQLITE_ROW != ret) && (SQLITE_DONE != ret)) // on row or no (more) row ready, else it's a problem
|
if ((SQLITE_ROW != ret) && (SQLITE_DONE != ret)) // on row or no (more) row ready, else it's a problem
|
||||||
|
{
|
||||||
|
if (ret == sqlite3_errcode(mStmtPtr))
|
||||||
{
|
{
|
||||||
throw SQLite::Exception(mStmtPtr, ret);
|
throw SQLite::Exception(mStmtPtr, ret);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw SQLite::Exception("Statement needs to be reseted", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mbHasRow; // true only if one row is accessible by getColumn(N)
|
return mbHasRow; // true only if one row is accessible by getColumn(N)
|
||||||
}
|
}
|
||||||
@ -276,10 +283,14 @@ int Statement::exec()
|
|||||||
{
|
{
|
||||||
throw SQLite::Exception("exec() does not expect results. Use executeStep.");
|
throw SQLite::Exception("exec() does not expect results. Use executeStep.");
|
||||||
}
|
}
|
||||||
else
|
else if (ret == sqlite3_errcode(mStmtPtr))
|
||||||
{
|
{
|
||||||
throw SQLite::Exception(mStmtPtr, ret);
|
throw SQLite::Exception(mStmtPtr, ret);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw SQLite::Exception("Statement needs to be reseted", ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number of rows modified by those SQL statements (INSERT, UPDATE or DELETE)
|
// Return the number of rows modified by those SQL statements (INSERT, UPDATE or DELETE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user