mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-27 17:49:19 +01:00
Make sure -1 and "" get stored in the database instead of NULL for song metadata. Thanks YellowOnion. Fixes issue #396. Fixes issue #479.
This commit is contained in:
parent
3f78df5725
commit
c35bd8779a
@ -251,5 +251,6 @@
|
||||
<file>icons/48x48/go-down.png</file>
|
||||
<file>hypnotoad.gif</file>
|
||||
<file>blank.ttf</file>
|
||||
<file>schema-16.sql</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
22
data/schema-16.sql
Normal file
22
data/schema-16.sql
Normal file
@ -0,0 +1,22 @@
|
||||
UPDATE songs SET title = "" WHERE title IS NULL;
|
||||
|
||||
UPDATE songs SET album = "" WHERE album IS NULL;
|
||||
|
||||
UPDATE songs SET artist = "" WHERE artist IS NULL;
|
||||
|
||||
UPDATE songs SET albumartist = "" WHERE albumartist IS NULL;
|
||||
|
||||
UPDATE songs SET composer = "" WHERE composer IS NULL;
|
||||
|
||||
UPDATE songs SET genre = "" WHERE genre IS NULL;
|
||||
|
||||
UPDATE songs SET track = -1 WHERE track IS NULL;
|
||||
|
||||
UPDATE songs SET disc = -1 WHERE disc IS NULL;
|
||||
|
||||
UPDATE songs SET bpm = -1 WHERE bpm IS NULL;
|
||||
|
||||
UPDATE songs SET year = -1 WHERE year IS NULL;
|
||||
|
||||
UPDATE schema_version SET version=16;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <QVariant>
|
||||
|
||||
const char* Database::kDatabaseFilename = "clementine.db";
|
||||
const int Database::kSchemaVersion = 15;
|
||||
const int Database::kSchemaVersion = 16;
|
||||
|
||||
int Database::sNextConnectionId = 1;
|
||||
QMutex Database::sNextConnectionIdMutex;
|
||||
|
@ -580,22 +580,23 @@ void Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
}
|
||||
|
||||
void Song::BindToQuery(QSqlQuery *query) const {
|
||||
#define intval(x) (x <= 0 ? QVariant() : x)
|
||||
#define strval(x) (x.isNull() ? "" : x)
|
||||
#define intval(x) (x <= 0 ? -1 : x)
|
||||
#define notnullintval(x) (x == -1 ? QVariant() : x)
|
||||
|
||||
// Remember to bind these in the same order as kBindSpec
|
||||
|
||||
query->bindValue(":title", d->title_);
|
||||
query->bindValue(":album", d->album_);
|
||||
query->bindValue(":artist", d->artist_);
|
||||
query->bindValue(":albumartist", d->albumartist_);
|
||||
query->bindValue(":composer", d->composer_);
|
||||
query->bindValue(":title", strval(d->title_));
|
||||
query->bindValue(":album", strval(d->album_));
|
||||
query->bindValue(":artist", strval(d->artist_));
|
||||
query->bindValue(":albumartist", strval(d->albumartist_));
|
||||
query->bindValue(":composer", strval(d->composer_));
|
||||
query->bindValue(":track", intval(d->track_));
|
||||
query->bindValue(":disc", intval(d->disc_));
|
||||
query->bindValue(":bpm", intval(d->bpm_));
|
||||
query->bindValue(":year", intval(d->year_));
|
||||
query->bindValue(":genre", d->genre_);
|
||||
query->bindValue(":comment", d->comment_);
|
||||
query->bindValue(":genre", strval(d->genre_));
|
||||
query->bindValue(":comment", strval(d->comment_));
|
||||
query->bindValue(":compilation", d->compilation_ ? 1 : 0);
|
||||
|
||||
query->bindValue(":length", intval(d->length_));
|
||||
|
@ -509,7 +509,7 @@ LibraryItem* LibraryModel::ItemFromQuery(GroupBy type,
|
||||
|
||||
case GroupBy_YearAlbum:
|
||||
year = qMax(0, q.Value(0).toInt());
|
||||
item->metadata.set_year(year);
|
||||
item->metadata.set_year(q.Value(0).toInt());
|
||||
item->metadata.set_album(q.Value(1).toString());
|
||||
item->key = PrettyYearAlbum(year, item->metadata.album());
|
||||
item->sort_text = SortTextForYear(year) + item->metadata.album();
|
||||
|
Loading…
x
Reference in New Issue
Block a user