From 053440c4a8211e326b6a934d87779c97b4e1d4f4 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Mon, 30 Mar 2020 15:43:22 -0300 Subject: [PATCH] Fix handling of null values in database migration to version 3 Some values prior to this version could be null, this wasn't handled properly before. --- .../java/org/schabi/newpipe/database/Migrations.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/Migrations.java b/app/src/main/java/org/schabi/newpipe/database/Migrations.java index ccb097a7b..c208853ce 100644 --- a/app/src/main/java/org/schabi/newpipe/database/Migrations.java +++ b/app/src/main/java/org/schabi/newpipe/database/Migrations.java @@ -81,8 +81,16 @@ public class Migrations { " duration INTEGER NOT NULL, uploader TEXT NOT NULL, thumbnail_url TEXT, view_count INTEGER, textual_upload_date TEXT, upload_date INTEGER," + " is_upload_date_approximation INTEGER)"); - database.execSQL("INSERT INTO streams_new (uid, service_id, url, title, stream_type, duration, uploader, thumbnail_url, view_count, textual_upload_date, upload_date, is_upload_date_approximation)"+ - " SELECT uid, service_id, url, title, stream_type, duration, uploader, thumbnail_url, NULL, NULL, NULL, NULL FROM streams"); + database.execSQL("INSERT INTO streams_new (uid, service_id, url, title, stream_type," + + "duration, uploader, thumbnail_url, view_count," + + "textual_upload_date, upload_date, is_upload_date_approximation) " + + + "SELECT uid, service_id, url, IFNULL(title, \"\"), IFNULL(stream_type, \"VIDEO_STREAM\")," + + "IFNULL(duration, 0), IFNULL(uploader, \"\"), IFNULL(thumbnail_url, \"\"), NULL," + + "NULL, NULL, NULL " + + + "FROM streams " + + "WHERE url IS NOT NULL"); database.execSQL("DROP TABLE streams"); database.execSQL("ALTER TABLE streams_new RENAME TO streams");