Fix boost::string_view compilation error of MysqlConnection class (#530)

This commit is contained in:
An Tao 2020-08-10 09:53:45 +08:00 committed by GitHub
parent 960309e615
commit 857cacfda7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -426,13 +426,15 @@ void MysqlConnection::execSqlInLoop(
seekPos = sql.find("?", pos); seekPos = sql.find("?", pos);
if (seekPos == std::string::npos) if (seekPos == std::string::npos)
{ {
sql_.append(sql.substr(pos)); auto sub = sql.substr(pos);
sql_.append(sub.data(), sub.length());
pos = seekPos; pos = seekPos;
break; break;
} }
else else
{ {
sql_.append(sql.substr(pos, seekPos - pos)); auto sub = sql.substr(pos, seekPos - pos);
sql_.append(sub.data(), sub.length());
pos = seekPos + 1; pos = seekPos + 1;
switch (format[i]) switch (format[i])
{ {
@ -473,12 +475,13 @@ void MysqlConnection::execSqlInLoop(
} }
if (pos < sql.length()) if (pos < sql.length())
{ {
sql_.append(sql.substr(pos)); auto sub = sql.substr(pos);
sql_.append(sub.data(), sub.length());
} }
} }
else else
{ {
sql_ = sql; sql_ = std::string(sql.data(), sql.length());
} }
LOG_TRACE << sql_; LOG_TRACE << sql_;
int err; int err;