Skip to content

Commit

Permalink
Merge pull request mixxxdj#13257 from Swiftb0y/fix/gh12894-single-quo…
Browse files Browse the repository at this point in the history
…te-sqlite-string-literals

Fix/gh12894 single quote sqlite string literals
  • Loading branch information
JoergAtGithub authored May 25, 2024
2 parents 1ca51f4 + ccc3e69 commit 3c70208
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
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

0 comments on commit 3c70208

Please sign in to comment.