Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/gh12894 single quote sqlite string literals #13257

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/library/banshee/bansheedbconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool BansheeDbConnection::open(const QString& databaseFile) {

int BansheeDbConnection::getSchemaVersion() {
QSqlQuery query(m_database);
query.prepare("SELECT Value FROM CoreConfiguration WHERE Key = \"DatabaseVersion\"");
query.prepare("SELECT Value FROM CoreConfiguration WHERE Key = 'DatabaseVersion'");

if (query.exec()) {
if (query.next()) {
Expand Down
84 changes: 46 additions & 38 deletions src/library/dao/autodjcratesdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,29 @@ bool AutoDJCratesDAO::updateLastPlayedDateTime() {
// WHERE newlastplayed != "";
QString strSetLog;
strSetLog.setNum(PlaylistDAO::PLHT_SET_LOG);
QString strQuery(QString ("INSERT OR REPLACE INTO " AUTODJCRATES_TABLE
" (" AUTODJCRATESTABLE_TRACKID ", " AUTODJCRATESTABLE_CRATEREFS ", "
AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS ", "
AUTODJCRATESTABLE_LASTPLAYED ")"
" SELECT * FROM (SELECT " PLAYLIST_TRACKS_TABLE ".%1, "
AUTODJCRATESTABLE_CRATEREFS ", " AUTODJCRATESTABLE_TIMESPLAYED ", "
AUTODJCRATESTABLE_AUTODJREFS ", MAX(%3) AS new"
AUTODJCRATESTABLE_LASTPLAYED " FROM " PLAYLIST_TRACKS_TABLE ", "
AUTODJCRATES_TABLE " WHERE " PLAYLIST_TRACKS_TABLE
".%2 IN (SELECT %4 FROM " PLAYLIST_TABLE " WHERE %5 = %6) AND "
PLAYLIST_TRACKS_TABLE ".%1 = " AUTODJCRATES_TABLE "."
AUTODJCRATESTABLE_TRACKID " GROUP BY " PLAYLIST_TRACKS_TABLE
".%1) WHERE new" AUTODJCRATESTABLE_LASTPLAYED " != \"\"")
.arg(PLAYLISTTRACKSTABLE_TRACKID, // %1
PLAYLISTTRACKSTABLE_PLAYLISTID, // %2
PLAYLISTTRACKSTABLE_DATETIMEADDED, // %3
PLAYLISTTABLE_ID, // %4
PLAYLISTTABLE_HIDDEN, // %5
strSetLog)); // %6
QString strQuery(QString(
"INSERT OR REPLACE INTO " AUTODJCRATES_TABLE
" (" AUTODJCRATESTABLE_TRACKID ", " AUTODJCRATESTABLE_CRATEREFS
", " AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS
", " AUTODJCRATESTABLE_LASTPLAYED
")"
" SELECT * FROM (SELECT " PLAYLIST_TRACKS_TABLE
".%1, " AUTODJCRATESTABLE_CRATEREFS
", " AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS
", MAX(%3) AS new" AUTODJCRATESTABLE_LASTPLAYED
" FROM " PLAYLIST_TRACKS_TABLE ", " AUTODJCRATES_TABLE
" WHERE " PLAYLIST_TRACKS_TABLE
".%2 IN (SELECT %4 FROM " PLAYLIST_TABLE
" WHERE %5 = %6) AND " PLAYLIST_TRACKS_TABLE
".%1 = " AUTODJCRATES_TABLE "." AUTODJCRATESTABLE_TRACKID
" GROUP BY " PLAYLIST_TRACKS_TABLE
".%1) WHERE new" AUTODJCRATESTABLE_LASTPLAYED " != ''")
.arg(PLAYLISTTRACKSTABLE_TRACKID, // %1
PLAYLISTTRACKSTABLE_PLAYLISTID, // %2
PLAYLISTTRACKSTABLE_DATETIMEADDED, // %3
PLAYLISTTABLE_ID, // %4
PLAYLISTTABLE_HIDDEN, // %5
strSetLog)); // %6
oQuery.prepare(strQuery);
if (!oQuery.exec()) {
LOG_FAILED_QUERY(oQuery);
Expand Down Expand Up @@ -507,26 +511,30 @@ bool AutoDJCratesDAO::updateLastPlayedDateTimeForTrack(TrackId trackId) {
// WHERE newlastplayed != "";
QString strSetLog;
strSetLog.setNum(PlaylistDAO::PLHT_SET_LOG);
oQuery.prepare(QString ("INSERT OR REPLACE INTO " AUTODJCRATES_TABLE
" (" AUTODJCRATESTABLE_TRACKID ", " AUTODJCRATESTABLE_CRATEREFS ", "
AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS ", "
AUTODJCRATESTABLE_LASTPLAYED ")"
" SELECT * FROM (SELECT " PLAYLIST_TRACKS_TABLE ".%1, "
AUTODJCRATESTABLE_CRATEREFS ", " AUTODJCRATESTABLE_TIMESPLAYED ", "
AUTODJCRATESTABLE_AUTODJREFS ", MAX(%3) AS new"
AUTODJCRATESTABLE_LASTPLAYED " FROM " PLAYLIST_TRACKS_TABLE ", "
AUTODJCRATES_TABLE " WHERE " PLAYLIST_TRACKS_TABLE
".%2 IN (SELECT %4 FROM " PLAYLIST_TABLE " WHERE %5 = %6) AND "
PLAYLIST_TRACKS_TABLE ".%1 = :track_id AND " PLAYLIST_TRACKS_TABLE
oQuery.prepare(QString(
"INSERT OR REPLACE INTO " AUTODJCRATES_TABLE
" (" AUTODJCRATESTABLE_TRACKID ", " AUTODJCRATESTABLE_CRATEREFS
", " AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS
", " AUTODJCRATESTABLE_LASTPLAYED
")"
" SELECT * FROM (SELECT " PLAYLIST_TRACKS_TABLE
".%1, " AUTODJCRATESTABLE_CRATEREFS
", " AUTODJCRATESTABLE_TIMESPLAYED ", " AUTODJCRATESTABLE_AUTODJREFS
", MAX(%3) AS new" AUTODJCRATESTABLE_LASTPLAYED
" FROM " PLAYLIST_TRACKS_TABLE ", " AUTODJCRATES_TABLE
" WHERE " PLAYLIST_TRACKS_TABLE
".%2 IN (SELECT %4 FROM " PLAYLIST_TABLE
" WHERE %5 = %6) AND " PLAYLIST_TRACKS_TABLE
".%1 = :track_id AND " PLAYLIST_TRACKS_TABLE
".%1 = " AUTODJCRATES_TABLE "." AUTODJCRATESTABLE_TRACKID
" GROUP BY " PLAYLIST_TRACKS_TABLE ".%1) WHERE new"
AUTODJCRATESTABLE_LASTPLAYED " != \"\"")
.arg(PLAYLISTTRACKSTABLE_TRACKID, // %1
PLAYLISTTRACKSTABLE_PLAYLISTID, // %2
PLAYLISTTRACKSTABLE_DATETIMEADDED, // %3
PLAYLISTTABLE_ID, // %4
PLAYLISTTABLE_HIDDEN, // %5
strSetLog)); // %6
" GROUP BY " PLAYLIST_TRACKS_TABLE
".%1) WHERE new" AUTODJCRATESTABLE_LASTPLAYED " != ''")
.arg(PLAYLISTTRACKSTABLE_TRACKID, // %1
PLAYLISTTRACKSTABLE_PLAYLISTID, // %2
PLAYLISTTRACKSTABLE_DATETIMEADDED, // %3
PLAYLISTTABLE_ID, // %4
PLAYLISTTABLE_HIDDEN, // %5
strSetLog)); // %6
oQuery.bindValue(":track_id", trackId.toVariant());
if (!oQuery.exec()) {
LOG_FAILED_QUERY(oQuery);
Expand Down
Loading