Skip to content

Commit

Permalink
fix(database): use-single-quote-continued
Browse files Browse the repository at this point in the history
fix(database): Use single-quoted SQLite string-literals as double-quoted are not disabled by default on SQlite >=3.41
  • Loading branch information
Swiftb0y committed May 22, 2024
1 parent 88310aa commit b953954
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 b953954

Please sign in to comment.