Fix database migration and string trimming

Co-authored-by:  Yingwei Zheng <dtcxzyw@qq.com>
This commit is contained in:
TobiGr 2023-08-16 22:01:58 +02:00
parent 90f0809029
commit 4af5b5f6f2
3 changed files with 21 additions and 23 deletions

View file

@ -239,8 +239,8 @@ public final class Migrations {
public static final Migration MIGRATION_7_8 = new Migration(DB_VER_7, DB_VER_8) {
@Override
public void migrate(@NonNull final SupportSQLiteDatabase database) {
database.execSQL("DELETE FROM search_history WHERE id NOT IN (SELECT id FROM "
+ "(SELECT id FROM search_history GROUP BY trim(search), service_id) tmp)");
database.execSQL("DELETE FROM search_history WHERE id NOT IN (SELECT id FROM (SELECT "
+ "MIN(id) as id FROM search_history GROUP BY trim(search), service_id ) tmp)");
database.execSQL("UPDATE search_history SET search = trim(search)");
}
};