Skip to content

Commit

Permalink
last played: this change breaks the PR. Why doesn't bindValue work??
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Apr 16, 2020
1 parent 06f4ed6 commit ff8a303
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/library/lastplayedcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ LastPlayedCache::LastPlayedCache(TrackCollection* trackCollection)
void LastPlayedCache::initTableView() {
// XXX: why isn't value binding working???
QSqlQuery lastPlayedQuery(m_pTrackCollection->database());
lastPlayedQuery.prepare(QStringLiteral(
"CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS "
lastPlayedQuery.prepare(
"CREATE TEMPORARY VIEW IF NOT EXISTS last_played AS "
"SELECT "
" PlaylistTracks.track_id, "
" MAX(PlaylistTracks.pl_datetime_added) as datetime_played "
"FROM PlaylistTracks "
"JOIN Playlists ON PlaylistTracks.playlist_id == Playlists.id "
"WHERE Playlists.hidden = %2 "
"GROUP BY PlaylistTracks.track_id")
.arg(LASTPLAYEDTABLE_NAME,
QString::number(PlaylistDAO::
PLHT_SET_LOG)));
"WHERE Playlists.hidden = :setlogid "
"GROUP BY PlaylistTracks.track_id");
// .arg(LASTPLAYEDTABLE_NAME));
lastPlayedQuery.bindValue(":setlogid", PlaylistDAO::PLHT_SET_LOG);
if (!lastPlayedQuery.exec()) {
LOG_FAILED_QUERY(lastPlayedQuery);
}
Expand All @@ -62,10 +61,10 @@ QDateTime LastPlayedCache::fetchLastPlayedTime(const QSqlDatabase& db, TrackPoin
" FROM "
" last_played "
" WHERE "
" track_id = %1 ")
.arg(pTrack->getId().toString());
updateQuery.prepare(queryString);
// updateQuery.bindValue(":trackId", trackId.toVariant());
" track_id = :trackid ");
// .arg(pTrack->getId().toString());
qDebug() << "yesSss????????????? " << updateQuery.prepare(queryString);

This comment has been minimized.

Copy link
@Pegasus-RPG

Pegasus-RPG Apr 16, 2020

Member

Can we get some more descriptive qDebug text here please?

This comment has been minimized.

Copy link
@ywwg

ywwg Apr 16, 2020

Author Member

obvi this is just for my testing -- this is printing "false" for the prepare step

This comment has been minimized.

Copy link
@ywwg

ywwg Apr 16, 2020

Author Member

finally found it: "parameters are not allowed in views" lol

updateQuery.bindValue(":trackid", pTrack->getId().toVariant(), QSql::Out);
if (!updateQuery.exec()) {
LOG_FAILED_QUERY(updateQuery);
}
Expand Down

0 comments on commit ff8a303

Please sign in to comment.