修改删除重复记录字段

v3.6.6
laoyuyu 5 years ago
parent a5fc5d0bcf
commit 1fb9f13dae
  1. 2
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  2. 12
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java

@ -38,7 +38,7 @@ class DBConfig {
static boolean DEBUG = false;
static Map<String, Class> mapping = new LinkedHashMap<>();
static String DB_NAME;
static int VERSION = 52;
static int VERSION = 53;
/**
* 是否将数据库保存在Sd卡{@code true}

@ -100,7 +100,7 @@ final class SqlHelper extends SQLiteOpenHelper {
handle360AriaUpdate(db);
} else if (oldVersion < 51) {
handle365Update(db);
} else if (oldVersion < 52) {
} else if (oldVersion < 53) {
handle366Update(db);
} else {
handleDbUpdate(db, null, null);
@ -240,12 +240,9 @@ final class SqlHelper extends SQLiteOpenHelper {
* 删除重复的repeat数据
*/
private void delRepeatThreadRecord(SQLiteDatabase db) {
String repeatSql =
"DELETE FROM ThreadRecord WHERE (taskKey, threadId, endLocation) "
+ "IN (SELECT taskKey, threadId, endLocation FROM ThreadRecord GROUP BY taskKey, threadId, endLocation "
+ "HAVING COUNT(*) > 1) AND rowid "
+ "NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY taskKey, threadId, endLocation "
+ "HAVING COUNT(*)> 1)";
String repeatSql = "DELETE FROM ThreadRecord WHERE (rowid) "
+ "IN (SELECT rowid FROM ThreadRecord GROUP BY taskKey, threadId, endLocation HAVING COUNT(*) > 1) "
+ "AND rowid NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY taskKey, threadId, endLocation HAVING COUNT(*)> 1)";
ALog.d(TAG, repeatSql);
db.execSQL(repeatSql);
}
@ -262,6 +259,7 @@ final class SqlHelper extends SQLiteOpenHelper {
// 执行升级操作
handleDbUpdate(db, modifyMap, null);
delRepeatThreadRecord(db);
}
/**

Loading…
Cancel
Save