Skip to content

Commit

Permalink
Use standard SQL quotes for string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrojo committed Aug 6, 2018
1 parent f977534 commit b6f47f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ColumnDisplayFormatDialog.cpp
Expand Up @@ -35,12 +35,12 @@ ColumnDisplayFormatDialog::ColumnDisplayFormatDialog(const QString& colname, QSt
formatFunctions["hex"] = "printf('0x%x', " + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["octal"] = "printf('%o', " + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["round"] = "round(" + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["appleDate"] = "datetime('2001-01-01', " + sqlb::escapeIdentifier(column_name) + " || \" seconds\")";
formatFunctions["appleDate"] = "datetime('2001-01-01', " + sqlb::escapeIdentifier(column_name) + " || ' seconds')";
formatFunctions["javaEpoch"] = "strftime('%Y-%m-%d %H:%M:%S.', " + sqlb::escapeIdentifier(column_name) +
"/1000, 'unixepoch') || (" + sqlb::escapeIdentifier(column_name) + "%1000)";
formatFunctions["julian"] = "datetime(" + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["epoch"] = "datetime(" + sqlb::escapeIdentifier(column_name) + ", 'unixepoch')";
formatFunctions["winDate"] = "datetime('1899-12-30', " + sqlb::escapeIdentifier(column_name) + " || \" days\")";
formatFunctions["winDate"] = "datetime('1899-12-30', " + sqlb::escapeIdentifier(column_name) + " || ' days')";
formatFunctions["ddmmyyyyDate"] = "strftime('%d/%m/%Y', " + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["lower"] = "lower(" + sqlb::escapeIdentifier(column_name) + ")";
formatFunctions["upper"] = "upper(" + sqlb::escapeIdentifier(column_name) + ")";
Expand Down
4 changes: 2 additions & 2 deletions src/sqlitedb.cpp
Expand Up @@ -134,7 +134,7 @@ bool DBBrowserDB::open(const QString& db, bool readOnly)
sqlite3_create_collation(_db, "UTF16", SQLITE_UTF16, nullptr, sqlite_compare_utf16);
// add UTF16CI (case insensitive) collation (comparison is performed by QString functions)
sqlite3_create_collation(_db, "UTF16CI", SQLITE_UTF16, nullptr, sqlite_compare_utf16ci);

// register collation callback
Callback<void(void*, sqlite3*, int, const char*)>::func = std::bind(&DBBrowserDB::collationNeeded, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4);
void (*c_callback)(void*, sqlite3*, int, const char*) = static_cast<decltype(c_callback)>(Callback<void(void*, sqlite3*, int, const char*)>::callback);
Expand Down Expand Up @@ -1672,7 +1672,7 @@ QString DBBrowserDB::getPragma(const QString& pragma)
bool DBBrowserDB::setPragma(const QString& pragma, const QString& value)
{
// Set the pragma value
QString sql = QString("PRAGMA %1 = \"%2\";").arg(pragma).arg(value);
QString sql = QString("PRAGMA %1 = '%2';").arg(pragma).arg(value);

// In general, we want to commit changes before running pragmas because most of them can't be rolled back and some of them
// even fail when run in a transaction. However, the defer_foreign_keys pragma has neither problem and we need it to be settable
Expand Down

0 comments on commit b6f47f9

Please sign in to comment.