mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-23 12:31:08 -06:00
Fix QStrings that had placeholders for queries
When replacing placeholders, QString::arg() looks for the sequence %n (where n is a number between 1 and 99). As it turns out this sequence can also appear in SQL queries and so they were being mistakenly replaced. See issue #203.
This commit is contained in:
@@ -773,8 +773,9 @@ void MainWindow::executeQuery()
|
||||
sqlWidget->getModel()->setQuery(queryPart);
|
||||
if(sqlWidget->getModel()->valid())
|
||||
{
|
||||
statusMessage = tr("%1 Rows returned from: %2 (took %3ms)").arg(
|
||||
sqlWidget->getModel()->totalRowCount()).arg(queryPart.trimmed()).arg(timer.elapsed());
|
||||
// The query takes the last placeholder as it may itself contain the sequence '%' + number
|
||||
statusMessage = tr("%1 Rows returned from: %3 (took %2ms)").arg(
|
||||
sqlWidget->getModel()->totalRowCount()).arg(timer.elapsed()).arg(queryPart.trimmed());
|
||||
sqlWidget->enableSaveButton(true);
|
||||
sql3status = SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ void SqliteTableModel::fetchData(unsigned int from, unsigned to)
|
||||
if(queryTemp.contains(QRegExp("LIMIT\\s+.+\\s*((,|\\b(OFFSET)\\b)\\s*.+\\s*)?$", Qt::CaseInsensitive)))
|
||||
sLimitQuery = queryTemp;
|
||||
else
|
||||
sLimitQuery = QString("%1 LIMIT %2, %3;").arg(queryTemp).arg(from).arg(to-from);
|
||||
sLimitQuery = queryTemp + QString(" LIMIT %1, %2;").arg(from).arg(to-from);
|
||||
}
|
||||
m_db->logSQL(sLimitQuery, kLogMsg_App);
|
||||
QByteArray utf8Query = sLimitQuery.toUtf8();
|
||||
|
||||
Reference in New Issue
Block a user