From a8a96b7631bbe7440c7ec0ef356327f6a78a5677 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 19 Feb 2022 17:13:57 +0100 Subject: [PATCH] Fix Room warning about unused columns during build The warning was: "The query returns some columns [...] which are not used by ..." --- .../schabi/newpipe/database/history/dao/StreamHistoryDAO.java | 2 ++ .../newpipe/database/playlist/dao/PlaylistStreamDAO.java | 2 ++ .../schabi/newpipe/database/subscription/SubscriptionDAO.kt | 3 +++ 3 files changed, 7 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java index 0a765ed4eec..150d4a8e5b5 100644 --- a/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/history/dao/StreamHistoryDAO.java @@ -3,6 +3,7 @@ import androidx.annotation.Nullable; import androidx.room.Dao; import androidx.room.Query; +import androidx.room.RewriteQueriesToDropUnusedColumns; import org.schabi.newpipe.database.history.model.StreamHistoryEntity; import org.schabi.newpipe.database.history.model.StreamHistoryEntry; @@ -67,6 +68,7 @@ public Flowable> listByService(final int serviceId) { @Query("DELETE FROM " + STREAM_HISTORY_TABLE + " WHERE " + JOIN_STREAM_ID + " = :streamId") public abstract int deleteStreamHistory(long streamId); + @RewriteQueriesToDropUnusedColumns @Query("SELECT * FROM " + STREAM_TABLE // Select the latest entry and watch count for each stream id on history table diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.java b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.java index f4a0a758085..4941d939507 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.java @@ -2,6 +2,7 @@ import androidx.room.Dao; import androidx.room.Query; +import androidx.room.RewriteQueriesToDropUnusedColumns; import androidx.room.Transaction; import org.schabi.newpipe.database.BasicDAO; @@ -52,6 +53,7 @@ default Flowable> listByService(final int serviceId) + " WHERE " + JOIN_PLAYLIST_ID + " = :playlistId") Flowable getMaximumIndexOf(long playlistId); + @RewriteQueriesToDropUnusedColumns @Transaction @Query("SELECT * FROM " + STREAM_TABLE + " INNER JOIN " // get ids of streams of the given playlist diff --git a/app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionDAO.kt b/app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionDAO.kt index 9798ec72dda..47b6f4dd9aa 100644 --- a/app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/subscription/SubscriptionDAO.kt @@ -4,6 +4,7 @@ import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query +import androidx.room.RewriteQueriesToDropUnusedColumns import androidx.room.Transaction import io.reactivex.rxjava3.core.Flowable import io.reactivex.rxjava3.core.Maybe @@ -31,6 +32,7 @@ abstract class SubscriptionDAO : BasicDAO { ) abstract fun getSubscriptionsFiltered(filter: String): Flowable> + @RewriteQueriesToDropUnusedColumns @Query( """ SELECT * FROM subscriptions s @@ -47,6 +49,7 @@ abstract class SubscriptionDAO : BasicDAO { currentGroupId: Long ): Flowable> + @RewriteQueriesToDropUnusedColumns @Query( """ SELECT * FROM subscriptions s