mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Ignore trailing spaces in sqlite3 statements, #585
This commit is contained in:
parent
09a98736d7
commit
46cffc8398
@ -74,9 +74,14 @@ namespace sqlpp
|
||||
|
||||
detail::prepared_statement_handle_t result{nullptr, handle->config->debug};
|
||||
|
||||
// ignore trailing spaces
|
||||
const auto end =
|
||||
std::find_if(statement.rbegin(), statement.rend(), [](char ch) { return !std::isspace(ch); }).base();
|
||||
const auto length = end - statement.begin();
|
||||
|
||||
const char* uncompiledTail = nullptr;
|
||||
const auto rc = sqlite3_prepare_v2(handle->native_handle(), statement.c_str(),
|
||||
static_cast<int>(statement.size()), &result.sqlite_statement, &uncompiledTail);
|
||||
static_cast<int>(length), &result.sqlite_statement, &uncompiledTail);
|
||||
|
||||
if (rc != SQLITE_OK)
|
||||
{
|
||||
@ -85,7 +90,7 @@ namespace sqlpp
|
||||
" ,statement was >>" + (rc == SQLITE_TOOBIG ? statement.substr(0, 128) + "..." : statement) + "<<\n"};
|
||||
}
|
||||
|
||||
if (uncompiledTail != statement.c_str() + statement.size())
|
||||
if (uncompiledTail != statement.c_str() + length)
|
||||
{
|
||||
throw sqlpp::exception{"Sqlite3 connector: Cannot execute multi-statements: >>" + statement + "<<\n"};
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ int Sample(int, char*[])
|
||||
alpha INTEGER PRIMARY KEY,
|
||||
beta varchar(255) DEFAULT NULL,
|
||||
gamma bool DEFAULT NULL
|
||||
))");
|
||||
)
|
||||
)");
|
||||
db.execute(R"(CREATE TABLE tab_foo (
|
||||
omega bigint(20) DEFAULT NULL
|
||||
))");
|
||||
|
Loading…
Reference in New Issue
Block a user