Use correct syntax when format applied to string containing apostrophe

The string has to be correctly quoted so contained apostrophes are doubled.

This prevented applying a format to cells containing apostrophes (single
quotes) since the SQL code raised a syntax error in SQLite.
This commit is contained in:
mgrojo
2019-12-27 13:02:49 +01:00
parent 0efb1aecdd
commit a287d8a27b

View File

@@ -272,7 +272,7 @@ QVariant SqliteTableModel::getMatchingCondFormat(const std::map<size_t, std::vec
if (isNumber && !contains(eachCondFormat.sqlCondition(), '\''))
sql = "SELECT " + value.toStdString() + " " + eachCondFormat.sqlCondition();
else
sql = "SELECT '" + value.toStdString() + "' " + eachCondFormat.sqlCondition();
sql = "SELECT " + sqlb::escapeString(value.toStdString()) + " " + eachCondFormat.sqlCondition();
// Empty filter means: apply format to any row.
// Query the DB for the condition, waiting in case there is a loading in progress.